|
|
@@ -323,6 +323,50 @@ class AdminView(LoginRequiredMixin, generic.ListView):
|
|
|
|
|
|
|
|
|
|
|
|
+class ProductsListView(generic.ListView):
|
|
|
+ model = Product
|
|
|
+ template_name='marktplatz/product_list.html'
|
|
|
+ embed = False
|
|
|
+
|
|
|
+ def get_context_data(self, **kwargs):
|
|
|
+ # context = super().get_context_data(**kwargs)
|
|
|
+ # return context
|
|
|
+ if self.embed :
|
|
|
+ kwargs['embed'] = True
|
|
|
+ return super().get_context_data(**kwargs)
|
|
|
+
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
+ # print (request.POST.dict())
|
|
|
+ context = request.POST.dict()
|
|
|
+ public = {k: v for k, v in context.items() if k.startswith('product_p')}
|
|
|
+
|
|
|
+ for elemk in public:
|
|
|
+ # print(elemk + " - " + public[elemk] )
|
|
|
+ keys = elemk.split(".")
|
|
|
+ current_product = Product.objects.get(pk=keys[1])
|
|
|
+ if public[elemk] == 'true':
|
|
|
+ current_product.public = True
|
|
|
+ current_product.save()
|
|
|
+ else:
|
|
|
+ current_product.public = False
|
|
|
+ current_product.save()
|
|
|
+
|
|
|
+ edit = {k: v for k, v in context.items() if k.startswith('product_e')}
|
|
|
+ # print (edit)
|
|
|
+ for elemk in edit:
|
|
|
+ # print(elemk + " - " + edit[elemk] )
|
|
|
+ keys = elemk.split(".")
|
|
|
+ current_product = Product.objects.get(pk=keys[1])
|
|
|
+ if edit[elemk] == 'true':
|
|
|
+ current_product.edit = True
|
|
|
+ current_product.save()
|
|
|
+ else:
|
|
|
+ current_product.edit = False
|
|
|
+ current_product.save()
|
|
|
+
|
|
|
+ return HttpResponseRedirect('')
|
|
|
+
|
|
|
+
|
|
|
|
|
|
class lightboximg(LoginRequiredMixin, TemplateView):
|
|
|
|