Browse Source

fix for multiple trigger in admin panel

Juan Carlos 5 năm trước cách đây
mục cha
commit
158f47b1d1
2 tập tin đã thay đổi với 9 bổ sung8 xóa
  1. 8 8
      marktplatz/views.py
  2. 1 0
      project_base/settings.py

+ 8 - 8
marktplatz/views.py

@@ -507,12 +507,12 @@ class AdminView(LoginRequiredMixin, generic.ListView):
             # print(elemk + " -  " + public[elemk] )
             # print(elemk + " -  " + public[elemk] )
             keys = elemk.split(".")
             keys = elemk.split(".")
             current_product = Product.objects.get(pk=keys[1])
             current_product = Product.objects.get(pk=keys[1])
-            if public[elemk] == 'true':
+            if public[elemk] == 'true' and current_product.public == False :
                 current_product.public = True
                 current_product.public = True
                 current_product.save()
                 current_product.save()
-            else:
-                current_product.public = False
-                current_product.save()
+            # else:
+            #     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)
@@ -520,12 +520,12 @@ class AdminView(LoginRequiredMixin, generic.ListView):
             # print(elemk + " -  " + edit[elemk] )
             # print(elemk + " -  " + edit[elemk] )
             keys = elemk.split(".")
             keys = elemk.split(".")
             current_product = Product.objects.get(pk=keys[1])
             current_product = Product.objects.get(pk=keys[1])
-            if edit[elemk] == 'true':
+            if edit[elemk] == 'true' and current_product.edit == False :
                 current_product.edit = True
                 current_product.edit = True
                 current_product.save()
                 current_product.save()
-            else:
-                current_product.edit = False
-                current_product.save()
+            # else:
+            #     current_product.edit = False
+            #     current_product.save()
 
 
         return HttpResponseRedirect('')
         return HttpResponseRedirect('')
 
 

+ 1 - 0
project_base/settings.py

@@ -258,6 +258,7 @@ NEWSLETTER_BATCH_SIZE = 100
 
 
 CRONJOBS = [
 CRONJOBS = [
     ('*/5 * * * *', 'django.core.management.call_command', ['submit_newsletter', ], '>   /dev/null 2>&1' ), #> /dev/null 2>&1
     ('*/5 * * * *', 'django.core.management.call_command', ['submit_newsletter', ], '>   /dev/null 2>&1' ), #> /dev/null 2>&1
+    ('* * * * *', 'django.core.management.call_command', ['send_queued_mail'], '> /dev/null 2>&1'),
 ]
 ]
 
 
 CRISPY_TEMPLATE_PACK = 'bootstrap4'
 CRISPY_TEMPLATE_PACK = 'bootstrap4'