Browse Source

further fix admin panel. edit removed

Juan Carlos 5 years ago
parent
commit
42568d0833
2 changed files with 37 additions and 36 deletions
  1. 20 18
      marktplatz/templates/marktplatz/admin_panel.html
  2. 17 18
      marktplatz/views.py

+ 20 - 18
marktplatz/templates/marktplatz/admin_panel.html

@@ -15,30 +15,32 @@
     <tr>
         <th scope="col"></th>
         <th scope="col"> Product</th>
-        <th scope="col"> Category</th>
+        <!-- <th scope="col"> Category</th> -->
         <th scope="col"> Public</th>
-        <th scope="col"> Editable </th>
-        <th scope="col"> submitted</th>
+        <!-- <th scope="col"> Editable </th>
+        <th scope="col"> submitted</th> -->
 
     </tr>
     {% for product in product_list %}
-    <tr class=""   >
-        <td  scope="col"><img src="{{product.media_set.first.image_small.url}}"  width="50" height="50" alt="{{ product.pk }}"> </td>
-        <td  scope="col"> <a href="{% url 'product-detail' product.pk %}">   {{product.name|upper }} </a></td>
-         <td scope="col">
+    <tr class="">
+      <td scope="col"><img src="{{product.media_set.first.image_small.url}}" width="50" height="50" alt="{{ product.pk }}"> </td>
+      <td scope="col"> <a href="{% url 'product-detail' product.pk %}"> {{product.name|upper }} </a></td>
+      <td scope="col">
         {% for category in product.category.all %}
         {{category.short_name}}{% if not forloop.last %} | {% endif %}
-             {% endfor %}
-        </td>
-        <td scope="col">
-          <input type="checkbox" class="form-check-input check" id="{{ product.pk }}.public_dummy" name="dummy_product_p.{{ product.pk }}.public" {% if product.public %}checked value="true"{% else %} value="false" {% endif %} onclick="if(this.checked){ this.nextElementSibling.setAttribute('value', 'true') }else{ this.nextElementSibling.setAttribute('value', 'false') }">
-          <input type="hidden"  class="hidden" id="{{ product.pk }}.public" name="product_p.{{ product.pk }}.public" {% if product.public %}value="true"{% else %} value="false" {% endif %} >
-</td>
-        <td scope="col">
-    <input type="checkbox" class="form-check-input check" id="{{ product.pk }}.edit_dummy" name="dummy_product_e.{{ product.pk }}.edit" {% if product.edit %}checked="checked"{% endif %} onclick="if(this.checked){ this.nextElementSibling.setAttribute('value', 'true') }else{ this.nextElementSibling.setAttribute('value', 'false') }" >
-    <input type="hidden"  class="hidden" id="{{ product.pk }}.edit" name="product_e.{{ product.pk }}.edit" {% if product.edit %}value="true"{% else %} value="false" {% endif %} >
- </td>
-        <td scope="col"> {{product.sumbitted}} </td>
+        {% endfor %}
+      </td>
+      <td scope="col">
+        <input type="checkbox" class="form-check-input check" id="{{ product.pk }}.public_dummy" name="dummy_product_p.{{ product.pk }}.public" {% if product.public %}checked value="true" {% else %} value="false" {% endif %}
+          onclick="if(this.checked){ this.nextElementSibling.setAttribute('value', 'true') }else{ this.nextElementSibling.setAttribute('value', 'false') }">
+        <input type="hidden" class="hidden" id="{{ product.pk }}.public" name="product_p.{{ product.pk }}.public" {% if product.public %}value="true" {% else %} value="false" {% endif %}>
+      </td>
+      <!-- <td scope="col">
+        <input type="checkbox" class="form-check-input check" id="{{ product.pk }}.edit_dummy" name="dummy_product_e.{{ product.pk }}.edit" {% if product.edit %}checked="checked" {% endif %}
+          onclick="if(this.checked){ this.nextElementSibling.setAttribute('value', 'true') }else{ this.nextElementSibling.setAttribute('value', 'false') }">
+        <input type="hidden" class="hidden" id="{{ product.pk }}.edit" name="product_e.{{ product.pk }}.edit" {% if product.edit %}value="true" {% else %} value="false" {% endif %}>
+      </td> -->
+      <!-- <td scope="col"> {{product.sumbitted}} </td> -->
 
     </tr>
     {% endfor %}

+ 17 - 18
marktplatz/views.py

@@ -504,28 +504,27 @@ class AdminView(LoginRequiredMixin, generic.ListView):
         public = {k: v for k, v in context.items() if k.startswith('product_p')}
 
         for elemk in public:
-            # print(elemk + " -  " + public[elemk] )
             keys = elemk.split(".")
             current_product = Product.objects.get(pk=keys[1])
-            if public[elemk] == 'true' and current_product.public == False :
-                current_product.public = True
+            if public[elemk] == 'true':
+                if current_product.public == False :
+                    current_product.public = True
+                    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')}
-        # print (edit)
-        for elemk in edit:
-            # print(elemk + " -  " + edit[elemk] )
-            keys = elemk.split(".")
-            current_product = Product.objects.get(pk=keys[1])
-            if edit[elemk] == 'true' and current_product.edit == False :
-                current_product.edit = True
-                current_product.save()
-            # else:
-            #     current_product.edit = False
-            #     current_product.save()
+        # edit = {k: v for k, v in context.items() if k.startswith('product_e')}
+        # for elemk in edit:
+        #     keys = elemk.split(".")
+        #     current_product = Product.objects.get(pk=keys[1])
+        #     if edit[elemk] == 'true'
+        #         if current_product.edit == False :
+        #             current_product.edit = True
+        #             current_product.save()
+        #     else:
+        #         current_product.edit = False
+        #         current_product.save()
 
         return HttpResponseRedirect('')