|
@@ -81,17 +81,21 @@ class SearchAgentCreate(CreateView):
|
|
|
success_url = reverse_lazy('products')
|
|
success_url = reverse_lazy('products')
|
|
|
|
|
|
|
|
class ProductsView(generic.ListView):
|
|
class ProductsView(generic.ListView):
|
|
|
- model = Product
|
|
|
|
|
|
|
+ model = Wohnprojekt
|
|
|
#context_object_name = 'Products'
|
|
#context_object_name = 'Products'
|
|
|
# show the best 4 website finish
|
|
# show the best 4 website finish
|
|
|
|
|
|
|
|
def get_queryset(self):
|
|
def get_queryset(self):
|
|
|
# original qs
|
|
# original qs
|
|
|
qs = super().get_queryset()
|
|
qs = super().get_queryset()
|
|
|
|
|
+
|
|
|
self.user = self.request.user
|
|
self.user = self.request.user
|
|
|
user = self.user
|
|
user = self.user
|
|
|
- if user.groups.filter(name='jury').exists():
|
|
|
|
|
- return qs.filter(sumbitted = config.CURRENT_EVENT)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # if user.groups.filter(name='jury').exists():
|
|
|
|
|
+ # return qs.filter(sumbitted = config.CURRENT_EVENT)
|
|
|
|
|
+
|
|
|
|
|
+ qs = qs.order_by('frei')
|
|
|
|
|
|
|
|
if user.groups.filter(name='submission').exists():
|
|
if user.groups.filter(name='submission').exists():
|
|
|
contact = Contact.objects.get(user=user)
|
|
contact = Contact.objects.get(user=user)
|
|
@@ -100,6 +104,7 @@ class ProductsView(generic.ListView):
|
|
|
if user.is_superuser:
|
|
if user.is_superuser:
|
|
|
return qs
|
|
return qs
|
|
|
|
|
|
|
|
|
|
+
|
|
|
return qs.filter(public = True)
|
|
return qs.filter(public = True)
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
def get_context_data(self, **kwargs):
|
|
@@ -107,22 +112,33 @@ class ProductsView(generic.ListView):
|
|
|
user =self.request.user
|
|
user =self.request.user
|
|
|
context['user'] = user
|
|
context['user'] = user
|
|
|
used_countries = []
|
|
used_countries = []
|
|
|
|
|
+ orts = {}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
years = {''}
|
|
years = {''}
|
|
|
- for product in context['product_list']:
|
|
|
|
|
|
|
+ for product in context['wohnprojekt_list']:
|
|
|
if not years.__contains__(product.year):
|
|
if not years.__contains__(product.year):
|
|
|
years.add(product.year)
|
|
years.add(product.year)
|
|
|
for country in product.country:
|
|
for country in product.country:
|
|
|
if not used_countries.__contains__(country):
|
|
if not used_countries.__contains__(country):
|
|
|
used_countries.append(country)
|
|
used_countries.append(country)
|
|
|
|
|
+ # if not used_orts.__contains__( product.get_ort_display() ):
|
|
|
|
|
+ if not product.ort in orts:
|
|
|
|
|
+ orts[product.ort] = product.get_ort_display()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
years.remove('')
|
|
years.remove('')
|
|
|
context['year_list'] = years
|
|
context['year_list'] = years
|
|
|
context['count_list'] = used_countries
|
|
context['count_list'] = used_countries
|
|
|
|
|
+ context['frei_list'] = Product.FREI
|
|
|
|
|
+ context['status_list'] = Product.STATUS
|
|
|
|
|
+ context['ort_dict'] = orts
|
|
|
|
|
|
|
|
|
|
+ context['altneu_list'] = Wohnprojekt.ALTNEU
|
|
|
|
|
|
|
|
- context['cat_list'] = Category.objects.all
|
|
|
|
|
|
|
|
|
|
context['sponsor_cards'] = Template( config.SPONSOR_CARDS ).render( Context(context) )
|
|
context['sponsor_cards'] = Template( config.SPONSOR_CARDS ).render( Context(context) )
|
|
|
context['main_card'] = Template( config.MAIN_CARD ).render( Context(context) )
|
|
context['main_card'] = Template( config.MAIN_CARD ).render( Context(context) )
|
|
@@ -235,26 +251,26 @@ class AdminView(LoginRequiredMixin, generic.ListView):
|
|
|
for elemk in public:
|
|
for elemk in public:
|
|
|
# print(elemk + " - " + public[elemk] )
|
|
# print(elemk + " - " + public[elemk] )
|
|
|
keys = elemk.split(".")
|
|
keys = elemk.split(".")
|
|
|
- now_Product = Product.objects.get(pk=keys[1])
|
|
|
|
|
|
|
+ current_product = Product.objects.get(pk=keys[1])
|
|
|
if public[elemk] == 'true':
|
|
if public[elemk] == 'true':
|
|
|
- now_Product.public = True
|
|
|
|
|
- now_Product.save()
|
|
|
|
|
|
|
+ current_product.public = True
|
|
|
|
|
+ current_product.save()
|
|
|
else:
|
|
else:
|
|
|
- now_Product.public = False
|
|
|
|
|
- now_Product.save()
|
|
|
|
|
|
|
+ current_product.public = False
|
|
|
|
|
+ current_product.save()
|
|
|
|
|
|
|
|
edit = {k: v for k, v in context.items() if k.startswith('product_e')}
|
|
edit = {k: v for k, v in context.items() if k.startswith('product_e')}
|
|
|
# print (edit)
|
|
# print (edit)
|
|
|
for elemk in edit:
|
|
for elemk in edit:
|
|
|
# print(elemk + " - " + edit[elemk] )
|
|
# print(elemk + " - " + edit[elemk] )
|
|
|
keys = elemk.split(".")
|
|
keys = elemk.split(".")
|
|
|
- now_Product = Product.objects.get(pk=keys[1])
|
|
|
|
|
|
|
+ current_product = Product.objects.get(pk=keys[1])
|
|
|
if edit[elemk] == 'true':
|
|
if edit[elemk] == 'true':
|
|
|
- now_Product.edit = True
|
|
|
|
|
- now_Product.save()
|
|
|
|
|
|
|
+ current_product.edit = True
|
|
|
|
|
+ current_product.save()
|
|
|
else:
|
|
else:
|
|
|
- now_Product.edit = False
|
|
|
|
|
- now_Product.save()
|
|
|
|
|
|
|
+ current_product.edit = False
|
|
|
|
|
+ current_product.save()
|
|
|
|
|
|
|
|
return HttpResponseRedirect('')
|
|
return HttpResponseRedirect('')
|
|
|
|
|
|
|
@@ -608,11 +624,15 @@ class EditView(FormView):
|
|
|
update_fields = []
|
|
update_fields = []
|
|
|
# https://stackoverflow.com/questions/35879101/how-to-determine-if-a-field-has-changed-in-a-django-modelform/43550210
|
|
# https://stackoverflow.com/questions/35879101/how-to-determine-if-a-field-has-changed-in-a-django-modelform/43550210
|
|
|
if product_f.has_changed():
|
|
if product_f.has_changed():
|
|
|
|
|
+ product = product_f.save( commit=False )
|
|
|
if 'frei' in product_f.changed_data:
|
|
if 'frei' in product_f.changed_data:
|
|
|
- print('frei changed')
|
|
|
|
|
- product_f.save( )
|
|
|
|
|
|
|
+ product.save( update_fields=['frei'] )
|
|
|
|
|
+ else:
|
|
|
|
|
+ product.save( )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- product = product_f.save()
|
|
|
|
|
|
|
+ # product = product_f.save()
|
|
|
# for lnk in lnks_f:
|
|
# for lnk in lnks_f:
|
|
|
# if lnk.is_valid():
|
|
# if lnk.is_valid():
|
|
|
# print( "link valid ......................." )
|
|
# print( "link valid ......................." )
|