|
|
@@ -284,7 +284,9 @@ class ProductPublish(LoginRequiredMixin, DetailView):
|
|
|
|
|
|
|
|
|
class ProductsView(generic.ListView):
|
|
|
- model = Wohnprojekt
|
|
|
+ model = Product
|
|
|
+ template_name = 'marktplatz/product_overview.html'
|
|
|
+ context_object_name = 'product_list'
|
|
|
#context_object_name = 'Products'
|
|
|
|
|
|
def get_queryset(self):
|
|
|
@@ -311,47 +313,62 @@ class ProductsView(generic.ListView):
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
user =self.request.user
|
|
|
context['user'] = user
|
|
|
- orts = {}
|
|
|
|
|
|
- raum_agebote = {}
|
|
|
+ context['textSearchForm'] = textSearchForm()
|
|
|
|
|
|
+ context['sponsor_cards'] = Template( config.SPONSOR_CARDS ).render( Context(context) )
|
|
|
+ context['main_card'] = Template( config.MAIN_CARD ).render( Context(context) )
|
|
|
|
|
|
- for product in context['wohnprojekt_list']:
|
|
|
+ orts = {}
|
|
|
+ for product in context['product_list']:
|
|
|
|
|
|
- # if not used_orts.__contains__( product.get_ort_display() ):
|
|
|
if not product.ort in orts:
|
|
|
orts[product.ort] = product.get_ort_display()
|
|
|
- # print (product.raumangebot.get_list() )
|
|
|
- for raum in product.raumangebot:
|
|
|
- if not (raum in raum_agebote):
|
|
|
- raum_agebote[raum] = product.raumangebot.choices[raum]
|
|
|
|
|
|
+ context['ort_dict'] = orts
|
|
|
|
|
|
context['frei_list'] = Product.FREI
|
|
|
- context['frei_list'][0] = ('JAJA', 'Wohnung frei')
|
|
|
context['status_list'] = Product.STATUS
|
|
|
- context['ort_dict'] = orts
|
|
|
- context['raum_agebote_dict'] = raum_agebote
|
|
|
|
|
|
- context['altneu_list'] = Wohnprojekt.ALTNEU
|
|
|
+ return context
|
|
|
|
|
|
- context['sponsor_cards'] = Template( config.SPONSOR_CARDS ).render( Context(context) )
|
|
|
- context['main_card'] = Template( config.MAIN_CARD ).render( Context(context) )
|
|
|
+class WohnprojekteView(ProductsView):
|
|
|
+ model = Wohnprojekt
|
|
|
+ template_name = 'marktplatz/product_overview.html'
|
|
|
|
|
|
+ def get_context_data(self, **kwargs):
|
|
|
+ context = super().get_context_data(**kwargs)
|
|
|
|
|
|
- context['textSearchForm'] = textSearchForm()
|
|
|
+ raum_agebote = {}
|
|
|
+
|
|
|
+ for product in context['product_list']:
|
|
|
+ for raum in product.raumangebot:
|
|
|
+ if not (raum in raum_agebote):
|
|
|
+ raum_agebote[raum] = product.raumangebot.choices[raum]
|
|
|
+
|
|
|
+ context['raum_agebote_dict'] = raum_agebote
|
|
|
+ context['frei_list'][0] = ('JAJA', 'Platz frei')
|
|
|
+ context['altneu_list'] = Wohnprojekt.ALTNEU
|
|
|
|
|
|
|
|
|
return context
|
|
|
|
|
|
- # def get(self, request, *args, **kwargs):
|
|
|
- # print(request.user_agent)
|
|
|
- # return super().get(self, request, *args, **kwargs)
|
|
|
|
|
|
+class MobilitaetsProjekteView(ProductsView):
|
|
|
+ model = MobilitaetsProjekt
|
|
|
+ template_name = 'marktplatz/product_overview.html'
|
|
|
+
|
|
|
+class ErnaerungsProjekteView(ProductsView):
|
|
|
+ model = ErnaehrungsProjekt
|
|
|
+ template_name = 'marktplatz/product_overview.html'
|
|
|
+
|
|
|
+class EnergyProjekteView(ProductsView):
|
|
|
+ model = EnergyProjekt
|
|
|
template_name = 'marktplatz/product_overview.html'
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
class FilterProductsView(ProductsView):
|
|
|
|
|
|
|
|
|
@@ -467,7 +484,6 @@ class WohnprojektDetailView(generic.DetailView):
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
class AdminView(LoginRequiredMixin, generic.ListView):
|
|
|
model = Product
|
|
|
template_name='marktplatz/admin_panel.html'
|
|
|
@@ -683,11 +699,11 @@ class registerView(FormView):
|
|
|
return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
-class NewProductView(LoginRequiredMixin, FormView):
|
|
|
- use_ajax = True
|
|
|
- template_name = 'marktplatz/add.html'
|
|
|
-
|
|
|
- model = Product
|
|
|
+# class NewProductView(LoginRequiredMixin, FormView):
|
|
|
+# use_ajax = True
|
|
|
+# template_name = 'marktplatz/add.html'
|
|
|
+#
|
|
|
+# model = Product
|
|
|
|
|
|
|
|
|
class ProductCreateView(LoginRequiredMixin, CreateView):
|
|
|
@@ -695,12 +711,6 @@ class ProductCreateView(LoginRequiredMixin, CreateView):
|
|
|
model = Product
|
|
|
form_class = ProductForm
|
|
|
gotoPics = False
|
|
|
- # success_url =
|
|
|
-
|
|
|
-
|
|
|
- # def get_success_url():
|
|
|
- # return reverse_lazy('add-image' date days)
|
|
|
-
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
@@ -722,8 +732,9 @@ class ProductCreateView(LoginRequiredMixin, CreateView):
|
|
|
else:
|
|
|
return HttpResponseRedirect( reverse('meine-projekte') )
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+class WohnProjektCreateView(ProductCreateView):
|
|
|
+ model = Wohnprojekt
|
|
|
+ form_class = WohnprojektForm
|
|
|
|
|
|
class MobilitaetsProjektCreateView(ProductCreateView):
|
|
|
model = MobilitaetsProjekt
|
|
|
@@ -737,43 +748,8 @@ class EnergyProjektCreateView(ProductCreateView):
|
|
|
model = EnergyProjekt
|
|
|
form_class = EnergyForm
|
|
|
|
|
|
-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)
|
|
|
|
|
|
|
|
|
|
|
|
@@ -785,14 +761,6 @@ class ProductUpdateView(LoginRequiredMixin, UpdateView):
|
|
|
# success_url =
|
|
|
|
|
|
|
|
|
- # def dispatch(self, request, *args, **kwargs):
|
|
|
- # if not request.user.is_authenticated:
|
|
|
- # return self.handle_no_permission()
|
|
|
- #
|
|
|
- # if self.model.check_manageable(request.user, id= kwargs['pk']):
|
|
|
- # return super().dispatch(request, *args, **kwargs)
|
|
|
- # raise PermissionDenied
|
|
|
-
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
@@ -830,6 +798,18 @@ class WohnProjektUpdateView(ProductUpdateView):
|
|
|
model = Wohnprojekt
|
|
|
form_class = WohnprojektForm
|
|
|
|
|
|
+class MobilitaetsProjektUpdateView(ProductUpdateView):
|
|
|
+ model = MobilitaetsProjekt
|
|
|
+ form_class = MobilitaetsForm
|
|
|
+
|
|
|
+class ErnaehrungsProjektUpdateView(ProductUpdateView):
|
|
|
+ model = ErnaehrungsProjekt
|
|
|
+ form_class = ErnaehrungsForm
|
|
|
+
|
|
|
+class EnergyProjektUpdateView(ProductUpdateView):
|
|
|
+ model = EnergyProjekt
|
|
|
+ form_class = EnergyForm
|
|
|
+
|
|
|
|
|
|
class addImageView(LoginRequiredMixin, FormView):
|
|
|
use_ajax = True
|
|
|
@@ -943,49 +923,49 @@ handle_upload = FileFormUploader()
|
|
|
|
|
|
|
|
|
|
|
|
-class EditView(LoginRequiredMixin, FormView):
|
|
|
-
|
|
|
- template_name = 'marktplatz/add.html'
|
|
|
-
|
|
|
- def get(self, request, pk):
|
|
|
- user = self.request.user
|
|
|
- contact = Contact.objects.get(user=user)
|
|
|
- if not Product.objects.filter(contact=contact).filter(pk=pk).exists():
|
|
|
- raise Http404
|
|
|
-
|
|
|
- context = request.GET.dict()
|
|
|
-
|
|
|
- context['product'] = WohnprojektForm(instance=Wohnprojekt.objects.get(pk=pk))
|
|
|
-
|
|
|
-
|
|
|
- context['use_ajax'] = True
|
|
|
- context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
-
|
|
|
- return render(request, self.template_name, context)
|
|
|
-
|
|
|
- def post(self, request, pk):
|
|
|
-
|
|
|
- product_f = WohnprojektForm(request.POST, request.FILES, instance=Wohnprojekt.objects.get(pk=pk))
|
|
|
-
|
|
|
- if product_f.is_valid():
|
|
|
- if product_f.has_changed():
|
|
|
- product = product_f.save( commit=False )
|
|
|
- update_fields = product_f.changed_data
|
|
|
- product.current_uri = request.build_absolute_uri( '/' ).rstrip('/')
|
|
|
- product.save( update_fields=update_fields )
|
|
|
- # product.save( )
|
|
|
-
|
|
|
- if 'add-image' in request.POST:
|
|
|
- return HttpResponseRedirect(reverse('add-image', kwargs={'pk': pk}))
|
|
|
-
|
|
|
- return HttpResponseRedirect(reverse('meine-projekte'))
|
|
|
-
|
|
|
- else:
|
|
|
- context = request.GET.dict()
|
|
|
- context['product'] = product_f
|
|
|
- context['product_errors'] = product_f.errors
|
|
|
- context['use_ajax'] = True
|
|
|
- return render(request, self.template_name, context)
|
|
|
+# class EditView(LoginRequiredMixin, FormView):
|
|
|
+#
|
|
|
+# template_name = 'marktplatz/add.html'
|
|
|
+#
|
|
|
+# def get(self, request, pk):
|
|
|
+# user = self.request.user
|
|
|
+# contact = Contact.objects.get(user=user)
|
|
|
+# if not Product.objects.filter(contact=contact).filter(pk=pk).exists():
|
|
|
+# raise Http404
|
|
|
+#
|
|
|
+# context = request.GET.dict()
|
|
|
+#
|
|
|
+# context['product'] = WohnprojektForm(instance=Wohnprojekt.objects.get(pk=pk))
|
|
|
+#
|
|
|
+#
|
|
|
+# context['use_ajax'] = True
|
|
|
+# context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
+#
|
|
|
+# return render(request, self.template_name, context)
|
|
|
+#
|
|
|
+# def post(self, request, pk):
|
|
|
+#
|
|
|
+# product_f = WohnprojektForm(request.POST, request.FILES, instance=Wohnprojekt.objects.get(pk=pk))
|
|
|
+#
|
|
|
+# if product_f.is_valid():
|
|
|
+# if product_f.has_changed():
|
|
|
+# product = product_f.save( commit=False )
|
|
|
+# update_fields = product_f.changed_data
|
|
|
+# product.current_uri = request.build_absolute_uri( '/' ).rstrip('/')
|
|
|
+# product.save( update_fields=update_fields )
|
|
|
+# # product.save( )
|
|
|
+#
|
|
|
+# if 'add-image' in request.POST:
|
|
|
+# return HttpResponseRedirect(reverse('add-image', kwargs={'pk': pk}))
|
|
|
+#
|
|
|
+# return HttpResponseRedirect(reverse('meine-projekte'))
|
|
|
+#
|
|
|
+# else:
|
|
|
+# context = request.GET.dict()
|
|
|
+# context['product'] = product_f
|
|
|
+# context['product_errors'] = product_f.errors
|
|
|
+# context['use_ajax'] = True
|
|
|
+# return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|