admin_panel.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {% extends "base_generic.html" %}
  2. {% load tags %}
  3. {% block content %}
  4. <div class="container-fluid">
  5. {% if user.is_superuser %}
  6. <h3 style="margin-top: 10px">Products Overview </h3>
  7. <form class="form-inline" method="POST"> {% csrf_token %}
  8. <table class="table table-sm table-hover">
  9. <thead class="">
  10. <tr>
  11. <th scope="col"></th>
  12. <th scope="col"> Product</th>
  13. <!-- <th scope="col"> Category</th> -->
  14. <th scope="col"> Public</th>
  15. <!-- <th scope="col"> Editable </th>
  16. <th scope="col"> submitted</th> -->
  17. </tr>
  18. </thead>
  19. {% for product in product_list %}
  20. <tr class="">
  21. <td scope="col"><img src="{{product.media_set.first.image_small.url}}" width="50" height="50" alt="{{ product.pk }}"> </td>
  22. <td scope="col"> <a href="{% url 'product-detail-type' type=product.type pk=product.pk %}"> {{product.name|upper }} </a></td>
  23. <!-- <td scope="col">
  24. {% for category in product.category.all %}
  25. {{category.short_name}}{% if not forloop.last %} | {% endif %}
  26. {% endfor %}
  27. </td> -->
  28. <td scope="col">
  29. <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 %}
  30. onclick="if(this.checked){ this.nextElementSibling.setAttribute('value', 'true') }else{ this.nextElementSibling.setAttribute('value', 'false') }">
  31. <input type="hidden" class="hidden" id="{{ product.pk }}.public" name="product_p.{{ product.pk }}.public" {% if product.public %}value="true" {% else %} value="false" {% endif %}>
  32. </td>
  33. <!-- <td scope="col">
  34. <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 %}
  35. onclick="if(this.checked){ this.nextElementSibling.setAttribute('value', 'true') }else{ this.nextElementSibling.setAttribute('value', 'false') }">
  36. <input type="hidden" class="hidden" id="{{ product.pk }}.edit" name="product_e.{{ product.pk }}.edit" {% if product.edit %}value="true" {% else %} value="false" {% endif %}>
  37. </td> -->
  38. <!-- <td scope="col"> {{product.sumbitted}} </td> -->
  39. </tr>
  40. {% endfor %}
  41. <script type="text/javascript">
  42. /* for reference, eventually replace the call of onclick */
  43. function changeCheck(elem){
  44. if(elem.checked){
  45. elem.setAttribute('value', 'true')
  46. }else{
  47. elem.setAttribute('value', 'false')
  48. }
  49. }
  50. </script>
  51. </table>
  52. <button class="btn border-dark rounded-0 mybtn" type="submit">Submit </button>
  53. </form>
  54. {% else %}
  55. <p>You are not authorized to view this page. </p>
  56. {% endif %}
  57. {% endblock %}