|
@@ -283,6 +283,16 @@ class ProductPublish(LoginRequiredMixin, DetailView):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
class ProductsView(generic.ListView):
|
|
class ProductsView(generic.ListView):
|
|
|
model = Product
|
|
model = Product
|
|
|
template_name = 'marktplatz/product_overview.html'
|
|
template_name = 'marktplatz/product_overview.html'
|
|
@@ -368,7 +378,6 @@ class EnergyProjekteView(ProductsView):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
class FilterProductsView(ProductsView):
|
|
class FilterProductsView(ProductsView):
|
|
|
|
|
|
|
|
|
|
|
|
@@ -391,7 +400,6 @@ class FilterProductsView(ProductsView):
|
|
|
if qfilter != "":
|
|
if qfilter != "":
|
|
|
self.object_list = self.get_queryset(qfilter= qfilter )
|
|
self.object_list = self.get_queryset(qfilter= qfilter )
|
|
|
|
|
|
|
|
-
|
|
|
|
|
allow_empty = self.get_allow_empty()
|
|
allow_empty = self.get_allow_empty()
|
|
|
|
|
|
|
|
# if not allow_empty:
|
|
# if not allow_empty:
|
|
@@ -452,35 +460,263 @@ class SearchProductsView(ProductsView):
|
|
|
return self.render_to_response(context)
|
|
return self.render_to_response(context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class ProductsListView(generic.ListView):
|
|
|
|
|
+ model = Product
|
|
|
|
|
+ template_name='marktplatz/product_list.html'
|
|
|
|
|
+ embed = False
|
|
|
|
|
+
|
|
|
|
|
+ def get_queryset(self):
|
|
|
|
|
+ # original qs
|
|
|
|
|
+ qs = super().get_queryset()
|
|
|
|
|
+
|
|
|
|
|
+ self.user = self.request.user
|
|
|
|
|
+ user = self.user
|
|
|
|
|
+
|
|
|
|
|
+ if user.is_superuser:
|
|
|
|
|
+ return qs
|
|
|
|
|
+
|
|
|
|
|
+ qs = qs.filter(public = True)
|
|
|
|
|
+
|
|
|
|
|
+ return qs
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ def get_context_data(self, **kwargs):
|
|
|
|
|
+
|
|
|
|
|
+ if self.embed :
|
|
|
|
|
+ kwargs['embed'] = True
|
|
|
|
|
+ return super().get_context_data(**kwargs)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#
|
|
|
|
|
+# DETAIL
|
|
|
|
|
+#
|
|
|
|
|
+
|
|
|
class ProduktDetailView(generic.DetailView):
|
|
class ProduktDetailView(generic.DetailView):
|
|
|
model = Product
|
|
model = Product
|
|
|
template_name = 'marktplatz/product_detail.html'
|
|
template_name = 'marktplatz/product_detail.html'
|
|
|
embed = False
|
|
embed = False
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
def get_context_data(self, **kwargs):
|
|
|
- # context = super().get_context_data(**kwargs)
|
|
|
|
|
|
|
|
|
|
if self.embed :
|
|
if self.embed :
|
|
|
- kwargs['embed'] = True
|
|
|
|
|
- # context['credits'] = Credit.objects.select_related().get(product = self.kwargs['pk'])
|
|
|
|
|
- # context['wohnprojekt'] = self.object.wohnprojekt
|
|
|
|
|
|
|
+ kwargs['embed'] = True
|
|
|
return super().get_context_data(**kwargs)
|
|
return super().get_context_data(**kwargs)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
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'])
|
|
|
|
|
|
|
|
return HttpResponseRedirect( reverse('products') )
|
|
return HttpResponseRedirect( reverse('products') )
|
|
|
|
|
|
|
|
|
|
+class ProduktGenericDetailView(ProduktDetailView):
|
|
|
|
|
+
|
|
|
|
|
+ def dispatch(self, request, *args, **kwargs):
|
|
|
|
|
+
|
|
|
|
|
+ if self.kwargs['type'] == 'BASE':
|
|
|
|
|
+ super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+ elif self.kwargs['type'] == 'WOHN':
|
|
|
|
|
+ self.model = Wohnprojekt
|
|
|
|
|
+ return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+ elif self.kwargs['type'] == 'MOBI':
|
|
|
|
|
+ self.model = MobilitaetsProjekt
|
|
|
|
|
+ return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+ elif self.kwargs['type'] == 'ERNA':
|
|
|
|
|
+ self.model = ErnaehrungsProjekt
|
|
|
|
|
+ return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+ elif self.kwargs['type'] == 'ENER':
|
|
|
|
|
+ self.model = EnergyProjekt
|
|
|
|
|
+ return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+
|
|
|
|
|
+ raise Http404('Keine Objekte gefunden')
|
|
|
|
|
+
|
|
|
|
|
+class WohnprojektDetailView(ProduktDetailView):
|
|
|
|
|
+ model = Wohnprojekt
|
|
|
|
|
+ template_name = 'marktplatz/product_detail.html'
|
|
|
|
|
+
|
|
|
|
|
+class MobilitaetsProjektDetailView(ProduktDetailView):
|
|
|
|
|
+ model = MobilitaetsProjekt
|
|
|
|
|
+ template_name = 'marktplatz/product_detail.html'
|
|
|
|
|
+
|
|
|
|
|
+class ErnaehrungsProjektDetailView(ProduktDetailView):
|
|
|
|
|
+ model = ErnaehrungsProjekt
|
|
|
|
|
+ template_name = 'marktplatz/product_detail.html'
|
|
|
|
|
+
|
|
|
|
|
+class EnergyProjektProjektDetailView(ProduktDetailView):
|
|
|
|
|
+ model = EnergyProjekt
|
|
|
|
|
+ template_name = 'marktplatz/product_detail.html'
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
class ProduktCardDetailView(ProduktDetailView):
|
|
class ProduktCardDetailView(ProduktDetailView):
|
|
|
|
|
|
|
|
template_name = 'marktplatz/product_detail_card.html'
|
|
template_name = 'marktplatz/product_detail_card.html'
|
|
|
|
|
|
|
|
-class WohnprojektDetailView(generic.DetailView):
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class ProductCreateView(LoginRequiredMixin, CreateView):
|
|
|
|
|
+ template_name = 'marktplatz/product_create.html'
|
|
|
|
|
+ model = Product
|
|
|
|
|
+ form_class = ProductForm
|
|
|
|
|
+ gotoPics = False
|
|
|
|
|
+
|
|
|
|
|
+ def get_context_data(self, **kwargs):
|
|
|
|
|
+ context = super().get_context_data(**kwargs)
|
|
|
|
|
+ context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
|
|
+ return context
|
|
|
|
|
+
|
|
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
|
|
+ if 'add-image' in request.POST:
|
|
|
|
|
+ self.gotoPics = True
|
|
|
|
|
+ return super().post(self, request, *args, **kwargs)
|
|
|
|
|
+
|
|
|
|
|
+ def form_valid(self, form):
|
|
|
|
|
+ product = form.save(commit=False)
|
|
|
|
|
+ product.contact = Contact.objects.get(user = self.request.user)
|
|
|
|
|
+ product.save()
|
|
|
|
|
+
|
|
|
|
|
+ if (self.gotoPics):
|
|
|
|
|
+ return HttpResponseRedirect(reverse('add-image', kwargs={'pk': product.pk}))
|
|
|
|
|
+ else:
|
|
|
|
|
+ return HttpResponseRedirect( reverse('meine-projekte') )
|
|
|
|
|
+
|
|
|
|
|
+class WohnProjektCreateView(ProductCreateView):
|
|
|
model = Wohnprojekt
|
|
model = Wohnprojekt
|
|
|
- template_name = 'marktplatz/wohnprojekt_detail.html'
|
|
|
|
|
- embed = False
|
|
|
|
|
|
|
+ form_class = WohnprojektForm
|
|
|
|
|
+
|
|
|
|
|
+class MobilitaetsProjektCreateView(ProductCreateView):
|
|
|
|
|
+ model = MobilitaetsProjekt
|
|
|
|
|
+ form_class = MobilitaetsForm
|
|
|
|
|
+
|
|
|
|
|
+class ErnaehrungsProjektCreateView(ProductCreateView):
|
|
|
|
|
+ model = ErnaehrungsProjekt
|
|
|
|
|
+ form_class = ErnaehrungsForm
|
|
|
|
|
+
|
|
|
|
|
+class EnergyProjektCreateView(ProductCreateView):
|
|
|
|
|
+ model = EnergyProjekt
|
|
|
|
|
+ form_class = EnergyForm
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class ProductUpdateView(LoginRequiredMixin, UpdateView):
|
|
|
|
|
+ template_name = 'marktplatz/product_create.html'
|
|
|
|
|
+ model = Product
|
|
|
|
|
+ form_class = ProductForm
|
|
|
|
|
+ gotoPics = False
|
|
|
|
|
+ # success_url =
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ def get_context_data(self, **kwargs):
|
|
|
|
|
+ context = super().get_context_data(**kwargs)
|
|
|
|
|
+ context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
|
|
+ return context
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ def get_object(self, queryset=None):
|
|
|
|
|
+ obj = super().get_object()
|
|
|
|
|
+ if ( obj.user_can_manage(self.request.user) ):
|
|
|
|
|
+ return obj
|
|
|
|
|
+ raise PermissionDenied
|
|
|
|
|
+
|
|
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
|
|
+ if 'add-image' in request.POST:
|
|
|
|
|
+ self.gotoPics = True
|
|
|
|
|
+ return super().post(self, request, *args, **kwargs)
|
|
|
|
|
+
|
|
|
|
|
+ def get(self, request, *args, **kwargs):
|
|
|
|
|
+ return super().get(self, request, *args, **kwargs)
|
|
|
|
|
+
|
|
|
|
|
+ def form_valid(self, form):
|
|
|
|
|
+
|
|
|
|
|
+ product = form.save(commit=False)
|
|
|
|
|
+ product.contact = Contact.objects.get(user = self.request.user)
|
|
|
|
|
+ product.save()
|
|
|
|
|
+
|
|
|
|
|
+ if (self.gotoPics):
|
|
|
|
|
+ return HttpResponseRedirect(reverse('add-image', kwargs={'pk': product.pk}))
|
|
|
|
|
+ else:
|
|
|
|
|
+ return HttpResponseRedirect( reverse('meine-projekte') )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class ProductGenericUpdateView(ProductUpdateView):
|
|
|
|
|
+
|
|
|
|
|
+ model = Product
|
|
|
|
|
+ form_class = ProductForm
|
|
|
|
|
+
|
|
|
|
|
+ def dispatch(self, request, *args, **kwargs):
|
|
|
|
|
+
|
|
|
|
|
+ if self.kwargs['type'] == 'BASE':
|
|
|
|
|
+ super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+ elif self.kwargs['type'] == 'WOHN':
|
|
|
|
|
+ self.model = Wohnprojekt
|
|
|
|
|
+ self.form_class = WohnprojektForm
|
|
|
|
|
+ return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+ elif self.kwargs['type'] == 'MOBI':
|
|
|
|
|
+ self.model = MobilitaetsProjekt
|
|
|
|
|
+ self.form_class = MobilitaetsForm
|
|
|
|
|
+ return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+ elif self.kwargs['type'] == 'ERNA':
|
|
|
|
|
+ self.model = ErnaehrungsProjekt
|
|
|
|
|
+ self.form_class = ErnaehrungsForm
|
|
|
|
|
+ return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+ elif self.kwargs['type'] == 'ENER':
|
|
|
|
|
+ self.model = EnergyProjekt
|
|
|
|
|
+ self.form_class = EnergyForm
|
|
|
|
|
+ return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
+
|
|
|
|
|
+ raise Http404('Keine Objekte gefunden' )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+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 UsersProducts(LoginRequiredMixin, generic.ListView):
|
|
|
|
|
+ model = Product
|
|
|
|
|
+ template_name='marktplatz/myProducts.html'
|
|
|
|
|
+
|
|
|
|
|
+ def get_queryset(self):
|
|
|
|
|
+ contact = Contact.objects.get(user=self.request.user)
|
|
|
|
|
+
|
|
|
|
|
+ wohnprojekte = Wohnprojekt.objects.filter(contact=contact)
|
|
|
|
|
+ mobilitaetsprojekte = MobilitaetsProjekt.objects.filter(contact=contact)
|
|
|
|
|
+ ernaehrungsprojekte = ErnaehrungsProjekt.objects.filter(contact=contact)
|
|
|
|
|
+ energyprojekte = EnergyProjekt.objects.filter(contact=contact)
|
|
|
|
|
+
|
|
|
|
|
+ projekte = list(itertools.chain(wohnprojekte, mobilitaetsprojekte, ernaehrungsprojekte, energyprojekte))
|
|
|
|
|
+
|
|
|
|
|
+ return projekte
|
|
|
|
|
+
|
|
|
|
|
+ def get_context_data(self, **kwargs):
|
|
|
|
|
+ context = super().get_context_data(**kwargs)
|
|
|
|
|
+ contact = Contact.objects.get(user=self.request.user)
|
|
|
|
|
+
|
|
|
|
|
+ context['user'] = self.request.user
|
|
|
|
|
+ return context
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -524,72 +760,6 @@ class AdminView(LoginRequiredMixin, generic.ListView):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-class ProductsListView(generic.ListView):
|
|
|
|
|
- model = Product
|
|
|
|
|
- template_name='marktplatz/product_list.html'
|
|
|
|
|
- embed = False
|
|
|
|
|
-
|
|
|
|
|
- def get_queryset(self):
|
|
|
|
|
- # original qs
|
|
|
|
|
- qs = super().get_queryset()
|
|
|
|
|
-
|
|
|
|
|
- self.user = self.request.user
|
|
|
|
|
- user = self.user
|
|
|
|
|
-
|
|
|
|
|
- if user.is_superuser:
|
|
|
|
|
- return qs
|
|
|
|
|
-
|
|
|
|
|
- qs = qs.filter(public = True)
|
|
|
|
|
-
|
|
|
|
|
- return qs
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- def get_context_data(self, **kwargs):
|
|
|
|
|
-
|
|
|
|
|
- if self.embed :
|
|
|
|
|
- kwargs['embed'] = True
|
|
|
|
|
- return super().get_context_data(**kwargs)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class lightboximg(LoginRequiredMixin, TemplateView):
|
|
|
|
|
-
|
|
|
|
|
- template_name = "marktplatz/importold.html"
|
|
|
|
|
-
|
|
|
|
|
- def post(self, request):
|
|
|
|
|
- context = {'faild': ''}
|
|
|
|
|
- faild = ''
|
|
|
|
|
- from1 = int(request.POST['from'])
|
|
|
|
|
- to = int(request.POST['to'])
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- products = Product.objects.all()
|
|
|
|
|
- i = 0
|
|
|
|
|
-
|
|
|
|
|
- for product in products:
|
|
|
|
|
- i+=1
|
|
|
|
|
- if (i < from1):
|
|
|
|
|
- continue
|
|
|
|
|
- if (i > to):
|
|
|
|
|
- break
|
|
|
|
|
-
|
|
|
|
|
- medias = product.media_set.all()
|
|
|
|
|
- for oldmedia in medias:
|
|
|
|
|
- if not oldmedia.image_norm:
|
|
|
|
|
- oldpic = oldmedia.image
|
|
|
|
|
- oldmedia.image_norm.save(oldmedia.filename() + '_norm', oldpic)
|
|
|
|
|
- oldmedia.save
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- return render(request, self.template_name, context)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- def get(self, request):
|
|
|
|
|
- context = {'faild': ''}
|
|
|
|
|
- faild = ''
|
|
|
|
|
- context['faild'] = faild
|
|
|
|
|
- return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|
class registerView(FormView):
|
|
class registerView(FormView):
|
|
|
|
|
|
|
@@ -699,153 +869,45 @@ class registerView(FormView):
|
|
|
return render(request, self.template_name, context)
|
|
return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|
|
|
|
-# class NewProductView(LoginRequiredMixin, FormView):
|
|
|
|
|
-# use_ajax = True
|
|
|
|
|
-# template_name = 'marktplatz/add.html'
|
|
|
|
|
-#
|
|
|
|
|
-# model = Product
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class ProductCreateView(LoginRequiredMixin, CreateView):
|
|
|
|
|
- template_name = 'marktplatz/product_create.html'
|
|
|
|
|
- model = Product
|
|
|
|
|
- form_class = ProductForm
|
|
|
|
|
- gotoPics = False
|
|
|
|
|
-
|
|
|
|
|
- def get_context_data(self, **kwargs):
|
|
|
|
|
- context = super().get_context_data(**kwargs)
|
|
|
|
|
- context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
|
|
- return context
|
|
|
|
|
-
|
|
|
|
|
- def post(self, request, *args, **kwargs):
|
|
|
|
|
- if 'add-image' in request.POST:
|
|
|
|
|
- self.gotoPics = True
|
|
|
|
|
- return super().post(self, request, *args, **kwargs)
|
|
|
|
|
-
|
|
|
|
|
- def form_valid(self, form):
|
|
|
|
|
- product = form.save(commit=False)
|
|
|
|
|
- product.contact = Contact.objects.get(user = self.request.user)
|
|
|
|
|
- product.save()
|
|
|
|
|
-
|
|
|
|
|
- if (self.gotoPics):
|
|
|
|
|
- return HttpResponseRedirect(reverse('add-image', kwargs={'pk': product.pk}))
|
|
|
|
|
- else:
|
|
|
|
|
- return HttpResponseRedirect( reverse('meine-projekte') )
|
|
|
|
|
-
|
|
|
|
|
-class WohnProjektCreateView(ProductCreateView):
|
|
|
|
|
- model = Wohnprojekt
|
|
|
|
|
- form_class = WohnprojektForm
|
|
|
|
|
-
|
|
|
|
|
-class MobilitaetsProjektCreateView(ProductCreateView):
|
|
|
|
|
- model = MobilitaetsProjekt
|
|
|
|
|
- form_class = MobilitaetsForm
|
|
|
|
|
-
|
|
|
|
|
-class ErnaehrungsProjektCreateView(ProductCreateView):
|
|
|
|
|
- model = ErnaehrungsProjekt
|
|
|
|
|
- form_class = ErnaehrungsForm
|
|
|
|
|
-
|
|
|
|
|
-class EnergyProjektCreateView(ProductCreateView):
|
|
|
|
|
- model = EnergyProjekt
|
|
|
|
|
- form_class = EnergyForm
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-# class ProductUpdateView(LoginRequiredMixin, View):
|
|
|
|
|
-#
|
|
|
|
|
-# def dispatch(request, *args, **kwargs):
|
|
|
|
|
-#
|
|
|
|
|
-# pass
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class ProductUpdateView(LoginRequiredMixin, UpdateView):
|
|
|
|
|
- template_name = 'marktplatz/product_create.html'
|
|
|
|
|
- model = Product
|
|
|
|
|
- form_class = ProductForm
|
|
|
|
|
- gotoPics = False
|
|
|
|
|
- # success_url =
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- def get_context_data(self, **kwargs):
|
|
|
|
|
- context = super().get_context_data(**kwargs)
|
|
|
|
|
- context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
|
|
- return context
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- def get_object(self, queryset=None):
|
|
|
|
|
- obj = super().get_object()
|
|
|
|
|
- if ( obj.user_can_manage(self.request.user) ):
|
|
|
|
|
- return obj
|
|
|
|
|
- raise PermissionDenied
|
|
|
|
|
-
|
|
|
|
|
- def post(self, request, *args, **kwargs):
|
|
|
|
|
- if 'add-image' in request.POST:
|
|
|
|
|
- self.gotoPics = True
|
|
|
|
|
- return super().post(self, request, *args, **kwargs)
|
|
|
|
|
-
|
|
|
|
|
- def get(self, request, *args, **kwargs):
|
|
|
|
|
- return super().get(self, request, *args, **kwargs)
|
|
|
|
|
-
|
|
|
|
|
- def form_valid(self, form):
|
|
|
|
|
-
|
|
|
|
|
- product = form.save(commit=False)
|
|
|
|
|
- product.contact = Contact.objects.get(user = self.request.user)
|
|
|
|
|
- product.save()
|
|
|
|
|
-
|
|
|
|
|
- if (self.gotoPics):
|
|
|
|
|
- return HttpResponseRedirect(reverse('add-image', kwargs={'pk': product.pk}))
|
|
|
|
|
- else:
|
|
|
|
|
- return HttpResponseRedirect( reverse('meine-projekte') )
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
+class lightboximg(LoginRequiredMixin, TemplateView):
|
|
|
|
|
|
|
|
-class ProductGenericUpdateView(ProductUpdateView):
|
|
|
|
|
|
|
+ template_name = "marktplatz/importold.html"
|
|
|
|
|
|
|
|
- model = Product
|
|
|
|
|
- form_class = ProductForm
|
|
|
|
|
|
|
+ def post(self, request):
|
|
|
|
|
+ context = {'faild': ''}
|
|
|
|
|
+ faild = ''
|
|
|
|
|
+ from1 = int(request.POST['from'])
|
|
|
|
|
+ to = int(request.POST['to'])
|
|
|
|
|
|
|
|
|
|
|
|
|
- def dispatch(self, request, *args, **kwargs):
|
|
|
|
|
|
|
+ products = Product.objects.all()
|
|
|
|
|
+ i = 0
|
|
|
|
|
|
|
|
- if self.kwargs['type'] == 'BASE':
|
|
|
|
|
- super().dispatch(request, *args, **kwargs)
|
|
|
|
|
- elif self.kwargs['type'] == 'WOHN':
|
|
|
|
|
- self.model = Wohnprojekt
|
|
|
|
|
- self.form_class = WohnprojektForm
|
|
|
|
|
- return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
- elif self.kwargs['type'] == 'MOBI':
|
|
|
|
|
- self.model = MobilitaetsProjekt
|
|
|
|
|
- self.form_class = MobilitaetsForm
|
|
|
|
|
- return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
- elif self.kwargs['type'] == 'ERNA':
|
|
|
|
|
- self.model = ErnaehrungsProjekt
|
|
|
|
|
- self.form_class = ErnaehrungsForm
|
|
|
|
|
- return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
- elif self.kwargs['type'] == 'ENER':
|
|
|
|
|
- self.model = EnergyProjekt
|
|
|
|
|
- self.form_class = EnergyForm
|
|
|
|
|
- return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
|
|
+ for product in products:
|
|
|
|
|
+ i+=1
|
|
|
|
|
+ if (i < from1):
|
|
|
|
|
+ continue
|
|
|
|
|
+ if (i > to):
|
|
|
|
|
+ break
|
|
|
|
|
|
|
|
- raise Http404('Keine Objekte gefunden' )
|
|
|
|
|
|
|
+ medias = product.media_set.all()
|
|
|
|
|
+ for oldmedia in medias:
|
|
|
|
|
+ if not oldmedia.image_norm:
|
|
|
|
|
+ oldpic = oldmedia.image
|
|
|
|
|
+ oldmedia.image_norm.save(oldmedia.filename() + '_norm', oldpic)
|
|
|
|
|
+ oldmedia.save
|
|
|
|
|
|
|
|
|
|
|
|
|
-class WohnProjektUpdateView(ProductUpdateView):
|
|
|
|
|
- model = Wohnprojekt
|
|
|
|
|
- form_class = WohnprojektForm
|
|
|
|
|
|
|
+ return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
-class MobilitaetsProjektUpdateView(ProductUpdateView):
|
|
|
|
|
- model = MobilitaetsProjekt
|
|
|
|
|
- form_class = MobilitaetsForm
|
|
|
|
|
|
|
|
|
|
-class ErnaehrungsProjektUpdateView(ProductUpdateView):
|
|
|
|
|
- model = ErnaehrungsProjekt
|
|
|
|
|
- form_class = ErnaehrungsForm
|
|
|
|
|
|
|
|
|
|
-class EnergyProjektUpdateView(ProductUpdateView):
|
|
|
|
|
- model = EnergyProjekt
|
|
|
|
|
- form_class = EnergyForm
|
|
|
|
|
|
|
+ def get(self, request):
|
|
|
|
|
+ context = {'faild': ''}
|
|
|
|
|
+ faild = ''
|
|
|
|
|
+ context['faild'] = faild
|
|
|
|
|
+ return render(request, self.template_name, context)
|
|
|
|
|
|
|
|
|
|
|
|
|
class addImageView(LoginRequiredMixin, FormView):
|
|
class addImageView(LoginRequiredMixin, FormView):
|
|
@@ -960,28 +1022,7 @@ handle_upload = FileFormUploader()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-class UsersProducts(LoginRequiredMixin, generic.ListView):
|
|
|
|
|
- model = Product
|
|
|
|
|
- template_name='marktplatz/myProducts.html'
|
|
|
|
|
-
|
|
|
|
|
- def get_queryset(self):
|
|
|
|
|
- contact = Contact.objects.get(user=self.request.user)
|
|
|
|
|
-
|
|
|
|
|
- wohnprojekte = Wohnprojekt.objects.filter(contact=contact)
|
|
|
|
|
- mobilitaetsprojekte = MobilitaetsProjekt.objects.filter(contact=contact)
|
|
|
|
|
- ernaehrungsprojekte = ErnaehrungsProjekt.objects.filter(contact=contact)
|
|
|
|
|
- energyprojekte = EnergyProjekt.objects.filter(contact=contact)
|
|
|
|
|
-
|
|
|
|
|
- projekte = list(itertools.chain(wohnprojekte, mobilitaetsprojekte, ernaehrungsprojekte, energyprojekte))
|
|
|
|
|
-
|
|
|
|
|
- return projekte
|
|
|
|
|
|
|
|
|
|
- def get_context_data(self, **kwargs):
|
|
|
|
|
- context = super().get_context_data(**kwargs)
|
|
|
|
|
- contact = Contact.objects.get(user=self.request.user)
|
|
|
|
|
-
|
|
|
|
|
- context['user'] = self.request.user
|
|
|
|
|
- return context
|
|
|
|
|
|
|
|
|
|
class MediaView(LoginRequiredMixin, TemplateView):
|
|
class MediaView(LoginRequiredMixin, TemplateView):
|
|
|
template_name = 'marktplatz/media_overview.html'
|
|
template_name = 'marktplatz/media_overview.html'
|