|
|
@@ -143,7 +143,6 @@ class genericView(TemplateView):
|
|
|
context = {}
|
|
|
context['object'] = model_to_dict ( instance )
|
|
|
context['object']['myfield'] = '----------------------------'
|
|
|
- # print (context)
|
|
|
return render(request, self.template_name, context )
|
|
|
|
|
|
|
|
|
@@ -152,7 +151,7 @@ class pagesView(TemplateView):
|
|
|
template_name = 'marktplatz/generic.html'
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
context = {}
|
|
|
- context['content_a'] = "lalalala"
|
|
|
+ context['content_a'] = ""
|
|
|
context['content_b'] = config
|
|
|
# print (config.items() )
|
|
|
|
|
|
@@ -290,79 +289,53 @@ class ProductPublish(LoginRequiredMixin, DetailView):
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
class ProductsView(generic.ListView):
|
|
|
model = Product
|
|
|
template_name = 'marktplatz/product_overview.html'
|
|
|
- context_object_name = 'product_list'
|
|
|
- #context_object_name = 'Products'
|
|
|
+ context_object_name = 'object_list'
|
|
|
|
|
|
+ def get_queryset(self):
|
|
|
|
|
|
- def filter_queryset(self, qs):
|
|
|
+ qs = super().get_queryset()
|
|
|
|
|
|
+ user = self.request.user
|
|
|
|
|
|
+ qs = qs.order_by('frei')
|
|
|
|
|
|
- user = self.request.user
|
|
|
if user.groups.filter(name='submission').exists():
|
|
|
contact = Contact.objects.get(user=user)
|
|
|
- qs = list ( filter( lambda product: (product.contact.pk == contact.pk) , qs ) )
|
|
|
- return qs
|
|
|
+ return qs.filter(contact = contact)
|
|
|
|
|
|
if user.is_superuser:
|
|
|
return qs
|
|
|
|
|
|
- qs = list ( filter( lambda product: (product.public == True) , qs ) )
|
|
|
-
|
|
|
- if 1==1:
|
|
|
- return qs
|
|
|
-
|
|
|
- def get_queryset(self):
|
|
|
-
|
|
|
- wohnprojekte = Wohnprojekt.objects.all()
|
|
|
- mobilitaetsprojekte = MobilitaetsProjekt.objects.all()
|
|
|
- ernaehrungsprojekte = ErnaehrungsProjekt.objects.all()
|
|
|
- energyprojekte = EnergyProjekt.objects.all()
|
|
|
-
|
|
|
- # qs = qs.order_by('frei')
|
|
|
- qs = sorted ( itertools.chain(wohnprojekte, mobilitaetsprojekte, ernaehrungsprojekte, energyprojekte), key= lambda product: product.frei )
|
|
|
+ qs = qs.filter(public = True)
|
|
|
|
|
|
- qs = self.filter_queryset(qs)
|
|
|
return qs
|
|
|
|
|
|
|
|
|
-
|
|
|
def get_context_data(self, **kwargs):
|
|
|
- context = super().get_context_data(**kwargs)
|
|
|
-
|
|
|
- orts = {}
|
|
|
- for product in context['product_list']:
|
|
|
+ context = super().get_context_data(**kwargs)
|
|
|
|
|
|
- if not product.ort in orts:
|
|
|
- orts[product.ort] = product.get_ort_display()
|
|
|
- context['ort_dict'] = orts
|
|
|
+ orts = {}
|
|
|
+ for product in context['object_list']:
|
|
|
+ if not product.ort in orts:
|
|
|
+ orts[product.ort] = product.get_ort_display()
|
|
|
+ context['ort_dict'] = orts
|
|
|
|
|
|
- user =self.request.user
|
|
|
- context['user'] = user
|
|
|
- context['frei_list'] = Product.FREI
|
|
|
- context['status_list'] = Product.STATUS
|
|
|
- context['sponsor_cards'] = Template( config.SPONSOR_CARDS ).render( Context(context) )
|
|
|
- context['main_card'] = Template( config.MAIN_CARD ).render( Context(context) )
|
|
|
- context['textSearchForm'] = textSearchForm()
|
|
|
+ context['user'] = self.request.user
|
|
|
+ context['frei_list'] = Product.FREI
|
|
|
+ context['status_list'] = Product.STATUS
|
|
|
+ context['sponsor_cards'] = Template( config.SPONSOR_CARDS ).render( Context(context) )
|
|
|
+ context['main_card'] = Template( config.MAIN_CARD ).render( Context(context) )
|
|
|
+ context['textSearchForm'] = textSearchForm()
|
|
|
|
|
|
- return context
|
|
|
+ return context
|
|
|
|
|
|
class WohnprojekteView(ProductsView):
|
|
|
model = Wohnprojekt
|
|
|
template_name = 'marktplatz/product_overview.html'
|
|
|
-
|
|
|
- def get_queryset(self):
|
|
|
-
|
|
|
- wohnprojekte = Wohnprojekt.objects.all()
|
|
|
- qs = sorted ( itertools.chain(wohnprojekte), key= lambda product: product.frei )
|
|
|
- qs = self.filter_queryset(qs)
|
|
|
- return qs
|
|
|
+ context_object_name = 'object_list'
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
@@ -380,38 +353,22 @@ class WohnprojekteView(ProductsView):
|
|
|
|
|
|
return context
|
|
|
|
|
|
-
|
|
|
class MobilitaetsProjekteView(ProductsView):
|
|
|
model = MobilitaetsProjekt
|
|
|
template_name = 'marktplatz/product_overview.html'
|
|
|
+ context_object_name = 'object_list'
|
|
|
|
|
|
- def get_queryset(self):
|
|
|
- mobilitaetsprojekte = MobilitaetsProjekt.objects.all()
|
|
|
- qs = sorted ( itertools.chain(mobilitaetsprojekte), key= lambda product: product.frei )
|
|
|
- qs = self.filter_queryset(qs)
|
|
|
- return qs
|
|
|
-
|
|
|
- # def get_context_data(self, *, object_list=self.qs, **kwargs):
|
|
|
|
|
|
class ErnaerungsProjekteView(ProductsView):
|
|
|
model = ErnaehrungsProjekt
|
|
|
template_name = 'marktplatz/product_overview.html'
|
|
|
-
|
|
|
- def get_queryset(self):
|
|
|
- ernaehrungsprojekte = ErnaehrungsProjekt.objects.all()
|
|
|
- qs = sorted ( itertools.chain(ernaehrungsprojekte), key= lambda product: product.frei )
|
|
|
- qs = self.filter_queryset(qs)
|
|
|
- return qs
|
|
|
+ context_object_name = 'object_list'
|
|
|
|
|
|
class EnergyProjekteView(ProductsView):
|
|
|
model = EnergyProjekt
|
|
|
template_name = 'marktplatz/product_overview.html'
|
|
|
+ context_object_name = 'object_list'
|
|
|
|
|
|
- def get_queryset(self):
|
|
|
- energyprojekte = EnergyProjekt.objects.all()
|
|
|
- qs = sorted ( itertools.chain(energyprojekte), key= lambda product: product.frei )
|
|
|
- qs = self.filter_queryset(qs)
|
|
|
- return qs
|
|
|
|
|
|
|
|
|
class FilterProductsView(ProductsView):
|
|
|
@@ -438,18 +395,6 @@ class FilterProductsView(ProductsView):
|
|
|
|
|
|
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)
|
|
|
|
|
|
@@ -462,8 +407,7 @@ class SearchProductsView(ProductsView):
|
|
|
# original qs
|
|
|
qs = super().get_queryset()
|
|
|
|
|
|
- self.user = self.request.user
|
|
|
- user = self.user
|
|
|
+ user = self.request.user
|
|
|
|
|
|
if qfilter!=None:
|
|
|
qs = qs.filter (name__icontains= qfilter) | qs.filter (claim__icontains= qfilter) | qs.filter (beschreibung__icontains= qfilter) | qs.filter (learning__icontains= qfilter) | qs.filter (status__icontains= qfilter) | qs.filter (adresse__icontains= qfilter) | qs.filter (plz__icontains= qfilter) | qs.filter (adresse__icontains= qfilter) | qs.filter (ort__icontains= qfilter) | qs.filter (website__icontains= qfilter) | qs.filter (email__icontains= qfilter) | qs.filter (kfrei__icontains= qfilter) | qs.filter (rechtsform__icontains= qfilter) | qs.filter (orga__icontains= qfilter)
|
|
|
@@ -493,6 +437,7 @@ class SearchProductsView(ProductsView):
|
|
|
'class_name': self.__class__.__name__,
|
|
|
})
|
|
|
context = self.get_context_data()
|
|
|
+ print(context)
|
|
|
return self.render_to_response(context)
|
|
|
|
|
|
|
|
|
@@ -500,7 +445,7 @@ class SearchProductsView(ProductsView):
|
|
|
|
|
|
class ProductsListView(generic.ListView):
|
|
|
model = Product
|
|
|
- template_name='marktplatz/product_list.html'
|
|
|
+ template_name='marktplatz/object_list.html'
|
|
|
embed = False
|
|
|
|
|
|
def get_queryset(self):
|
|
|
@@ -810,17 +755,6 @@ class AdminView(LoginRequiredMixin, generic.ListView):
|
|
|
current_product.public = False
|
|
|
current_product.save()
|
|
|
|
|
|
- # edit = {k: v for k, v in context.items() if k.startswith('product_e')}
|
|
|
- # for elemk in edit:
|
|
|
- # keys = elemk.split(".")
|
|
|
- # current_product = Product.objects.get(pk=keys[1])
|
|
|
- # if edit[elemk] == 'true'
|
|
|
- # if current_product.edit == False :
|
|
|
- # current_product.edit = True
|
|
|
- # current_product.save()
|
|
|
- # else:
|
|
|
- # current_product.edit = False
|
|
|
- # current_product.save()
|
|
|
|
|
|
return HttpResponseRedirect('')
|
|
|
|
|
|
@@ -983,11 +917,11 @@ class addImageView(LoginRequiredMixin, FormView):
|
|
|
def get(self, request, pk):
|
|
|
user = self.request.user
|
|
|
contact = Contact.objects.get(user=user)
|
|
|
- print (contact.id)
|
|
|
+ # print (contact.id)
|
|
|
product = Product.objects.filter(contact=contact)
|
|
|
|
|
|
if not Product.objects.filter(contact=contact).filter(pk=pk).exists():
|
|
|
- print( "no product 1" )
|
|
|
+ # print( "no product 1" )
|
|
|
raise Http404
|
|
|
|
|
|
product = Product.objects.get(pk=pk)
|
|
|
@@ -996,7 +930,7 @@ class addImageView(LoginRequiredMixin, FormView):
|
|
|
|
|
|
context = request.GET.dict()
|
|
|
contact = Contact.objects.get(user=self.request.user)
|
|
|
- print( "before 404" )
|
|
|
+ # print( "before 404" )
|
|
|
product = get_object_or_404(Product, (Q(pk=pk) & Q(contact=contact)))
|
|
|
context['product'] = product
|
|
|
context['images'] = Media.objects.filter(product=product)
|