|
@@ -67,7 +67,7 @@ def error_404_view(request, exception):
|
|
|
def home(request):
|
|
def home(request):
|
|
|
user = request.user
|
|
user = request.user
|
|
|
if user.groups.filter(name='submission').exists():
|
|
if user.groups.filter(name='submission').exists():
|
|
|
- return HttpResponseRedirect(reverse('my-products'))
|
|
|
|
|
|
|
+ return HttpResponseRedirect(reverse('meine-projekte'))
|
|
|
else:
|
|
else:
|
|
|
return HttpResponseRedirect(reverse('products'))
|
|
return HttpResponseRedirect(reverse('products'))
|
|
|
|
|
|
|
@@ -449,27 +449,26 @@ class DetailView(generic.DetailView):
|
|
|
|
|
|
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs):
|
|
def post(self, request, *args, **kwargs):
|
|
|
- vote = int(request.POST['vote'])
|
|
|
|
|
|
|
+ # vote = int(request.POST['vote'])
|
|
|
comment = str(request.POST['comment'])
|
|
comment = str(request.POST['comment'])
|
|
|
|
|
|
|
|
|
|
+ # if vote <= 10:
|
|
|
|
|
+ #
|
|
|
|
|
+ # try:
|
|
|
|
|
+ # get_vote = Vote.objects.get(juryMember=self.request.user, product=self.kwargs['pk'])
|
|
|
|
|
+ #
|
|
|
|
|
+ # get_vote.vote = vote
|
|
|
|
|
+ # get_vote.comment = comment
|
|
|
|
|
+ # get_vote.save()
|
|
|
|
|
+ #
|
|
|
|
|
+ #
|
|
|
|
|
+ # except Vote.DoesNotExist:
|
|
|
|
|
+ #
|
|
|
|
|
+ # get_vote = Vote(product = Product.objects.get(pk=self.kwargs['pk']), juryMember= self.request.user, vote = vote, comment=comment)
|
|
|
|
|
+ # get_vote.save()
|
|
|
|
|
|
|
|
- if vote <= 10:
|
|
|
|
|
-
|
|
|
|
|
- try:
|
|
|
|
|
- get_vote = Vote.objects.get(juryMember=self.request.user, product=self.kwargs['pk'])
|
|
|
|
|
-
|
|
|
|
|
- get_vote.vote = vote
|
|
|
|
|
- get_vote.comment = comment
|
|
|
|
|
- get_vote.save()
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- except Vote.DoesNotExist:
|
|
|
|
|
-
|
|
|
|
|
- get_vote = Vote(product = Product.objects.get(pk=self.kwargs['pk']), juryMember= self.request.user, vote = vote, comment=comment)
|
|
|
|
|
- get_vote.save()
|
|
|
|
|
-
|
|
|
|
|
- else:
|
|
|
|
|
- return HttpResponseRedirect(request.path)
|
|
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # return HttpResponseRedirect(request.path)
|
|
|
|
|
|
|
|
return HttpResponseRedirect(reverse('products'))
|
|
return HttpResponseRedirect(reverse('products'))
|
|
|
|
|
|
|
@@ -698,64 +697,97 @@ class NewProductView(LoginRequiredMixin, FormView):
|
|
|
|
|
|
|
|
model = Product
|
|
model = Product
|
|
|
|
|
|
|
|
-class NewWohnprojektView(LoginRequiredMixin, FormView):
|
|
|
|
|
- # use_ajax = True
|
|
|
|
|
- template_name = 'marktplatz/add.html'
|
|
|
|
|
|
|
|
|
|
|
|
+class ProductCreateView(CreateView, LoginRequiredMixin):
|
|
|
|
|
+ template_name = 'marktplatz/product_create.html'
|
|
|
model = Product
|
|
model = Product
|
|
|
-
|
|
|
|
|
- def get(self, request,*args, **kwargs):
|
|
|
|
|
- # form = self.form_class()
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- context = request.GET.dict()
|
|
|
|
|
- context['product'] = WohnprojektForm
|
|
|
|
|
- # context['use_ajax'] = True
|
|
|
|
|
- context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- return render(request, self.template_name, context)
|
|
|
|
|
|
|
+ form_class = ProductForm
|
|
|
|
|
+ gotoPics = False
|
|
|
|
|
+ # success_url =
|
|
|
|
|
|
|
|
|
|
|
|
|
- def post(self, request):
|
|
|
|
|
|
|
+ # def get_success_url():
|
|
|
|
|
+ # return reverse_lazy('add-image' date days)
|
|
|
|
|
|
|
|
- product_f = WohnprojektForm(request.POST, request.FILES)
|
|
|
|
|
|
|
|
|
|
- if product_f.is_valid():
|
|
|
|
|
|
|
+ def get_context_data(self, **kwargs):
|
|
|
|
|
+ context = super().get_context_data(**kwargs)
|
|
|
|
|
+ context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
|
|
+ return context
|
|
|
|
|
|
|
|
- product = product_f.save(commit=False)
|
|
|
|
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
|
|
+ if 'add-image' in request.POST:
|
|
|
|
|
+ self.gotoPics = True
|
|
|
|
|
+ return super().post(self, request, *args, **kwargs)
|
|
|
|
|
|
|
|
- product.contact = Contact.objects.get(user = self.request.user)
|
|
|
|
|
|
|
+ def form_valid(self, form):
|
|
|
|
|
+ product = form.save(commit=False)
|
|
|
|
|
+ product.contact = Contact.objects.get(user = self.request.user)
|
|
|
|
|
+ product.save()
|
|
|
|
|
|
|
|
- product.edit=True
|
|
|
|
|
- product.public = False
|
|
|
|
|
- product.sumbitted = config.CURRENT_EVENT
|
|
|
|
|
|
|
+ if (self.gotoPics):
|
|
|
|
|
+ return HttpResponseRedirect(reverse('add-image', kwargs={'pk': product.pk}))
|
|
|
|
|
+ else:
|
|
|
|
|
+ return HttpResponseRedirect( reverse('meine-projekte') )
|
|
|
|
|
|
|
|
- product.save( )
|
|
|
|
|
- # product_f.save_m2m()
|
|
|
|
|
|
|
|
|
|
- if 'addImage' in request.POST:
|
|
|
|
|
- return HttpResponseRedirect(reverse('add-Image', kwargs={'pk': product.pk}))
|
|
|
|
|
|
|
|
|
|
- return HttpResponseRedirect(reverse('my-products'))
|
|
|
|
|
|
|
+class MobilitaetsProjektCreateView(ProductCreateView):
|
|
|
|
|
+ model = MobilitaetsProjekt
|
|
|
|
|
+ form_class = MobilitaetsForm
|
|
|
|
|
|
|
|
- else:
|
|
|
|
|
|
|
|
|
|
- context = request.POST.dict()
|
|
|
|
|
- context['product'] = product_f
|
|
|
|
|
- context['product_errors'] = product_f.errors
|
|
|
|
|
- # context['use_ajax'] = True
|
|
|
|
|
- return render(request, self.template_name, context)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class uploadView(LoginRequiredMixin, FormView):
|
|
|
|
|
|
|
+class WohnProjektCreateView(ProductCreateView):
|
|
|
|
|
+ model = Wohnprojekt
|
|
|
|
|
+ form_class = WohnprojektForm
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+# class NewWohnprojektView(LoginRequiredMixin, FormView):
|
|
|
|
|
+# template_name = 'marktplatz/add.html'
|
|
|
|
|
+# model = Product
|
|
|
|
|
+#
|
|
|
|
|
+# def get(self, request,*args, **kwargs):
|
|
|
|
|
+# context = request.GET.dict()
|
|
|
|
|
+# context['product'] = WohnprojektForm
|
|
|
|
|
+# context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
|
|
+#
|
|
|
|
|
+# return render(request, self.template_name, context)
|
|
|
|
|
+#
|
|
|
|
|
+#
|
|
|
|
|
+# def post(self, request):
|
|
|
|
|
+#
|
|
|
|
|
+# product_f = WohnprojektForm(request.POST, request.FILES)
|
|
|
|
|
+#
|
|
|
|
|
+# if product_f.is_valid():
|
|
|
|
|
+# product = product_f.save(commit=False)
|
|
|
|
|
+# product.contact = Contact.objects.get(user = self.request.user)
|
|
|
|
|
+# product.save( )
|
|
|
|
|
+#
|
|
|
|
|
+# if 'add-image' in request.POST:
|
|
|
|
|
+# return HttpResponseRedirect(reverse('add-image', kwargs={'pk': product.pk}))
|
|
|
|
|
+#
|
|
|
|
|
+# return HttpResponseRedirect(reverse('meine-projekte'))
|
|
|
|
|
+#
|
|
|
|
|
+# else:
|
|
|
|
|
+#
|
|
|
|
|
+# context = request.POST.dict()
|
|
|
|
|
+# context['product'] = product_f
|
|
|
|
|
+# context['product_errors'] = product_f.errors
|
|
|
|
|
+# return render(request, self.template_name, context)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class addImageView(LoginRequiredMixin, FormView):
|
|
|
use_ajax = True
|
|
use_ajax = True
|
|
|
template_name = 'marktplatz/file_upload.html'
|
|
template_name = 'marktplatz/file_upload.html'
|
|
|
|
|
|
|
|
def get(self, request, pk):
|
|
def get(self, request, pk):
|
|
|
user = self.request.user
|
|
user = self.request.user
|
|
|
contact = Contact.objects.get(user=user)
|
|
contact = Contact.objects.get(user=user)
|
|
|
|
|
+ print (contact.id)
|
|
|
|
|
+ product = Product.objects.filter(contact=contact)
|
|
|
|
|
+
|
|
|
if not Product.objects.filter(contact=contact).filter(pk=pk).exists():
|
|
if not Product.objects.filter(contact=contact).filter(pk=pk).exists():
|
|
|
|
|
+ print( "no product 1" )
|
|
|
raise Http404
|
|
raise Http404
|
|
|
|
|
|
|
|
product = Product.objects.get(pk=pk)
|
|
product = Product.objects.get(pk=pk)
|
|
@@ -764,7 +796,8 @@ class uploadView(LoginRequiredMixin, FormView):
|
|
|
|
|
|
|
|
context = request.GET.dict()
|
|
context = request.GET.dict()
|
|
|
contact = Contact.objects.get(user=self.request.user)
|
|
contact = Contact.objects.get(user=self.request.user)
|
|
|
- product = get_object_or_404(Wohnprojekt, (Q(pk=pk) & Q(contact=contact)))
|
|
|
|
|
|
|
+ print( "before 404" )
|
|
|
|
|
+ product = get_object_or_404(Product, (Q(pk=pk) & Q(contact=contact)))
|
|
|
context['product'] = product
|
|
context['product'] = product
|
|
|
context['images'] = Media.objects.filter(product=product)
|
|
context['images'] = Media.objects.filter(product=product)
|
|
|
context['video'] = Video.objects.filter(product=product)
|
|
context['video'] = Video.objects.filter(product=product)
|
|
@@ -776,7 +809,7 @@ class uploadView(LoginRequiredMixin, FormView):
|
|
|
if video >= 2:
|
|
if video >= 2:
|
|
|
context['video_count'] = True
|
|
context['video_count'] = True
|
|
|
|
|
|
|
|
- context['use_ajax'] = True
|
|
|
|
|
|
|
+ # context['use_ajax'] = True
|
|
|
context['warning'] = False
|
|
context['warning'] = False
|
|
|
|
|
|
|
|
return render(request, self.template_name, context)
|
|
return render(request, self.template_name, context)
|
|
@@ -887,10 +920,10 @@ class EditView(LoginRequiredMixin, FormView):
|
|
|
product.save( update_fields=update_fields )
|
|
product.save( update_fields=update_fields )
|
|
|
# product.save( )
|
|
# product.save( )
|
|
|
|
|
|
|
|
- if 'addImage' in request.POST:
|
|
|
|
|
- return HttpResponseRedirect(reverse('add-Image', kwargs={'pk': pk}))
|
|
|
|
|
|
|
+ if 'add-image' in request.POST:
|
|
|
|
|
+ return HttpResponseRedirect(reverse('add-image', kwargs={'pk': pk}))
|
|
|
|
|
|
|
|
- return HttpResponseRedirect(reverse('my-products'))
|
|
|
|
|
|
|
+ return HttpResponseRedirect(reverse('meine-projekte'))
|
|
|
|
|
|
|
|
else:
|
|
else:
|
|
|
context = request.GET.dict()
|
|
context = request.GET.dict()
|