|
@@ -39,7 +39,6 @@ from django.db.models import Q
|
|
|
from newsletter.forms import *
|
|
from newsletter.forms import *
|
|
|
from newsletter.views import *
|
|
from newsletter.views import *
|
|
|
|
|
|
|
|
-# from .forms import LinkFormSet, LinkForm, FormsetHelper, MediaFormsetHelper, MediaFormSet
|
|
|
|
|
from marktplatz.models import *
|
|
from marktplatz.models import *
|
|
|
from .forms import *
|
|
from .forms import *
|
|
|
|
|
|
|
@@ -52,18 +51,14 @@ def about(request):
|
|
|
context = {}
|
|
context = {}
|
|
|
context = {'about_text': Template(config.ABOUT_CONTENT).render(Context(context))}
|
|
context = {'about_text': Template(config.ABOUT_CONTENT).render(Context(context))}
|
|
|
return render(request, 'marktplatz/about.html', context)
|
|
return render(request, 'marktplatz/about.html', context)
|
|
|
- #template = Template( config.ABOUT_CONTENT )
|
|
|
|
|
- #return HttpResponse( template.render( Context(context) ) )
|
|
|
|
|
- #return render(request, rendered , context = context)
|
|
|
|
|
|
|
|
|
|
def submit(request):
|
|
def submit(request):
|
|
|
context = {}
|
|
context = {}
|
|
|
context = {'submit_text': Template(config.SUBMIT_TEXT).render(Context(context))}
|
|
context = {'submit_text': Template(config.SUBMIT_TEXT).render(Context(context))}
|
|
|
return render(request,'marktplatz/submit.html', context)
|
|
return render(request,'marktplatz/submit.html', context)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
def error_404_view(request, exception):
|
|
def error_404_view(request, exception):
|
|
|
- data = {"name": "ThePythonDjango.com"}
|
|
|
|
|
|
|
+ data = {"name": "Markplatz"}
|
|
|
return render(request,'marktplatz/error_404.html', data)
|
|
return render(request,'marktplatz/error_404.html', data)
|
|
|
|
|
|
|
|
@login_required
|
|
@login_required
|
|
@@ -107,19 +102,6 @@ class AgentNewslwtterSubscribeView(SubscribeRequestView):
|
|
|
# kwargs['news_form'] = SubscribeRequestForm()
|
|
# kwargs['news_form'] = SubscribeRequestForm()
|
|
|
return super().get_context_data(**kwargs)
|
|
return super().get_context_data(**kwargs)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- # def get_form_kwargs(self):
|
|
|
|
|
- # """ Add ip to form kwargs for submitted forms. """
|
|
|
|
|
- # kwargs = super(SubscribeRequestView, self).get_form_kwargs()
|
|
|
|
|
- #
|
|
|
|
|
- # if self.request.method in ('POST', 'PUT'):
|
|
|
|
|
- # kwargs['ip'] = self.request.META.get('REMOTE_ADDR')
|
|
|
|
|
- #
|
|
|
|
|
- # return kwargs
|
|
|
|
|
- #
|
|
|
|
|
- # def get_subscription(self, form):
|
|
|
|
|
- # return form.save()
|
|
|
|
|
-
|
|
|
|
|
def post(self, request, *args, **kwargs):
|
|
def post(self, request, *args, **kwargs):
|
|
|
|
|
|
|
|
data = request.POST.copy()
|
|
data = request.POST.copy()
|
|
@@ -213,7 +195,6 @@ class SearchAgentDelete(DeleteView):
|
|
|
template_name = 'marktplatz/form.html'
|
|
template_name = 'marktplatz/form.html'
|
|
|
success_url = reverse_lazy('products')
|
|
success_url = reverse_lazy('products')
|
|
|
|
|
|
|
|
-
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
|
|
|
|
searchagent = get_object_or_404(SearchAgent, pk= kwargs.get('pk') )
|
|
searchagent = get_object_or_404(SearchAgent, pk= kwargs.get('pk') )
|
|
@@ -223,11 +204,49 @@ class SearchAgentDelete(DeleteView):
|
|
|
if settings.DEBUG:
|
|
if settings.DEBUG:
|
|
|
return render(request, self.template_name, context )
|
|
return render(request, self.template_name, context )
|
|
|
else:
|
|
else:
|
|
|
- super().get(self, request, *args, **kwargs)
|
|
|
|
|
|
|
+ return super().get(self, request, *args, **kwargs)
|
|
|
else:
|
|
else:
|
|
|
context['form_content'] = 'Oopala, das hat nicht geklappt.'
|
|
context['form_content'] = 'Oopala, das hat nicht geklappt.'
|
|
|
return render(request, self.template_name, context )
|
|
return render(request, self.template_name, context )
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class ProductDelete(LoginRequiredMixin, DeleteView):
|
|
|
|
|
+ model = Product
|
|
|
|
|
+ template_name = 'marktplatz/form.html'
|
|
|
|
|
+ success_url = reverse_lazy('products')
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ def get(self, request, *args, **kwargs):
|
|
|
|
|
+
|
|
|
|
|
+ contact = get_object_or_404(Contact, user= self.request.user ) # Contact.objects.get(user=self.request.user)
|
|
|
|
|
+ product = get_object_or_404(Product, pk= kwargs.get('pk') )
|
|
|
|
|
+
|
|
|
|
|
+ if (contact.id == product.contact.id) :
|
|
|
|
|
+ return super(ProductDelete, self).get(self, request, *args, **kwargs)
|
|
|
|
|
+ else:
|
|
|
|
|
+ raise Http404
|
|
|
|
|
+
|
|
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
|
|
+
|
|
|
|
|
+ contact = get_object_or_404(Contact, user= self.request.user ) # Contact.objects.get(user=self.request.user)
|
|
|
|
|
+ product = get_object_or_404(Product, pk= kwargs.get('pk') )
|
|
|
|
|
+
|
|
|
|
|
+ if (contact.id == product.contact.id) :
|
|
|
|
|
+ context = {}
|
|
|
|
|
+ context['form_content'] = 'Dein Projekt wird gelöscht, wenn die Seite live ist!'
|
|
|
|
|
+ if settings.DEBUG:
|
|
|
|
|
+ return render(request, self.template_name, context )
|
|
|
|
|
+ else:
|
|
|
|
|
+ return super().post(self, request, *args, **kwargs)
|
|
|
|
|
+ else:
|
|
|
|
|
+ raise Http404
|
|
|
|
|
+
|
|
|
|
|
+ context = {}
|
|
|
|
|
+ context['form_content'] = 'Oopala, das hat nicht geklappt.'
|
|
|
|
|
+ return render(request, self.template_name, context )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
class ProductsView(generic.ListView):
|
|
class ProductsView(generic.ListView):
|
|
|
model = Wohnprojekt
|
|
model = Wohnprojekt
|
|
|
#context_object_name = 'Products'
|
|
#context_object_name = 'Products'
|
|
@@ -432,11 +451,10 @@ class ProductsListView(generic.ListView):
|
|
|
embed = False
|
|
embed = False
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
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)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if self.embed :
|
|
|
|
|
+ kwargs['embed'] = True
|
|
|
|
|
+ return super().get_context_data(**kwargs)
|
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs):
|
|
def post(self, request, *args, **kwargs):
|
|
|
# print (request.POST.dict())
|
|
# print (request.POST.dict())
|
|
@@ -635,8 +653,6 @@ class NewWohnprojektView(LoginRequiredMixin, FormView):
|
|
|
|
|
|
|
|
context = request.GET.dict()
|
|
context = request.GET.dict()
|
|
|
context['product'] = WohnprojektForm
|
|
context['product'] = WohnprojektForm
|
|
|
- # context['lnks'] = LinkFormSet
|
|
|
|
|
- # context['lnks_helper'] = FormsetHelper()
|
|
|
|
|
context['use_ajax'] = True
|
|
context['use_ajax'] = True
|
|
|
context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
|
|
|
|
|
@@ -796,10 +812,6 @@ class EditView(LoginRequiredMixin, FormView):
|
|
|
|
|
|
|
|
context['product'] = WohnprojektForm(instance=Wohnprojekt.objects.get(pk=pk))
|
|
context['product'] = WohnprojektForm(instance=Wohnprojekt.objects.get(pk=pk))
|
|
|
|
|
|
|
|
- # linkFormSet = inlineformset_factory(Product,Link, form=LinkForm, extra=0)
|
|
|
|
|
- # myLinkFormSet = linkFormSet(instance= Product.objects.get(pk=pk) )
|
|
|
|
|
- # context['lnks'] = myLinkFormSet
|
|
|
|
|
- # context['lnks_helper'] = FormsetHelper()
|
|
|
|
|
|
|
|
|
|
context['use_ajax'] = True
|
|
context['use_ajax'] = True
|
|
|
context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
context['info_txt'] = Template(config.INFO_TXT).render(Context(context))
|
|
@@ -808,9 +820,6 @@ class EditView(LoginRequiredMixin, FormView):
|
|
|
|
|
|
|
|
def post(self, request, pk):
|
|
def post(self, request, pk):
|
|
|
|
|
|
|
|
- # print ( request.POST.dict() )
|
|
|
|
|
- # https://stackoverflow.com/questions/35879101/how-to-determine-if-a-field-has-changed-in-a-django-modelform/43550210
|
|
|
|
|
- # print ('product_f.changed_data: ', product_f.changed_data)
|
|
|
|
|
product_f = WohnprojektForm(request.POST, request.FILES, instance=Wohnprojekt.objects.get(pk=pk))
|
|
product_f = WohnprojektForm(request.POST, request.FILES, instance=Wohnprojekt.objects.get(pk=pk))
|
|
|
|
|
|
|
|
if product_f.is_valid():
|
|
if product_f.is_valid():
|
|
@@ -818,7 +827,6 @@ class EditView(LoginRequiredMixin, FormView):
|
|
|
product = product_f.save( commit=False )
|
|
product = product_f.save( commit=False )
|
|
|
update_fields = product_f.changed_data
|
|
update_fields = product_f.changed_data
|
|
|
product.current_uri = request.build_absolute_uri( '/' ).rstrip('/')
|
|
product.current_uri = request.build_absolute_uri( '/' ).rstrip('/')
|
|
|
-
|
|
|
|
|
product.save( update_fields=update_fields )
|
|
product.save( update_fields=update_fields )
|
|
|
# product.save( )
|
|
# product.save( )
|
|
|
|
|
|
|
@@ -828,14 +836,9 @@ class EditView(LoginRequiredMixin, FormView):
|
|
|
return HttpResponseRedirect(reverse('my-products'))
|
|
return HttpResponseRedirect(reverse('my-products'))
|
|
|
|
|
|
|
|
else:
|
|
else:
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- print( "not saved xxxxxxx" )
|
|
|
|
|
context = request.GET.dict()
|
|
context = request.GET.dict()
|
|
|
context['product'] = product_f
|
|
context['product'] = product_f
|
|
|
context['product_errors'] = product_f.errors
|
|
context['product_errors'] = product_f.errors
|
|
|
- # context['lnks'] = lnks_f
|
|
|
|
|
- # context['lnks_helper'] = FormsetHelper()
|
|
|
|
|
context['use_ajax'] = True
|
|
context['use_ajax'] = True
|
|
|
return render(request, self.template_name, context)
|
|
return render(request, self.template_name, context)
|
|
|
|
|
|