|
@@ -323,6 +323,50 @@ class ProductsView(generic.ListView):
|
|
|
|
|
|
|
|
template_name = 'marktplatz/product_overview.html'
|
|
template_name = 'marktplatz/product_overview.html'
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class FilterProductsView(ProductsView):
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ def get_queryset(self, qfilter=None, **kwargs ):
|
|
|
|
|
+ # original qs
|
|
|
|
|
+ qs = super().get_queryset()
|
|
|
|
|
+
|
|
|
|
|
+ if qfilter!=None:
|
|
|
|
|
+ mfilter = {}
|
|
|
|
|
+ mfilter[qfilter] = True
|
|
|
|
|
+ qs = qs.filter ( **mfilter )
|
|
|
|
|
+
|
|
|
|
|
+ qs = qs.order_by('frei')
|
|
|
|
|
+
|
|
|
|
|
+ return qs.filter(public = True)
|
|
|
|
|
+
|
|
|
|
|
+ def get(self, request, *args, **kwargs):
|
|
|
|
|
+
|
|
|
|
|
+ qfilter = kwargs.get('filter', "")
|
|
|
|
|
+ if qfilter != "":
|
|
|
|
|
+ self.object_list = self.get_queryset(qfilter= qfilter )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ allow_empty = self.get_allow_empty()
|
|
|
|
|
+
|
|
|
|
|
+ # if not allow_empty:
|
|
|
|
|
+ # # When pagination is enabled and object_list is a queryset,
|
|
|
|
|
+ # # it's better to do a cheap query than to load the unpaginated
|
|
|
|
|
+ # # queryset in memory.
|
|
|
|
|
+ # if self.get_paginate_by(self.object_list) is not None and hasattr(self.object_list, 'exists'):
|
|
|
|
|
+ # is_empty = not self.object_list.exists()
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # is_empty = not self.object_list
|
|
|
|
|
+ # if is_empty:
|
|
|
|
|
+ # raise Http404(_("Empty list and '%(class_name)s.allow_empty' is False.") % {
|
|
|
|
|
+ # 'class_name': self.__class__.__name__,
|
|
|
|
|
+ # })
|
|
|
|
|
+ context = self.get_context_data()
|
|
|
|
|
+ return self.render_to_response(context)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
class SearchProductsView(ProductsView):
|
|
class SearchProductsView(ProductsView):
|
|
|
|
|
|
|
|
|
|
|
|
@@ -475,38 +519,6 @@ class ProductsListView(generic.ListView):
|
|
|
kwargs['embed'] = True
|
|
kwargs['embed'] = True
|
|
|
return super().get_context_data(**kwargs)
|
|
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):
|
|
class lightboximg(LoginRequiredMixin, TemplateView):
|