Files
eam-project/templates/products/products-data.html
T
2025-05-23 14:44:12 +08:00

64 lines
3.0 KiB
HTML

{% if page_object %}
{% for products in page_object %}
<tr>
<td>
{% if page_object.start_index %}
{{page_object.start_index|add:forloop.counter0}}
{% else %}
{{forloop.counter}}
{% endif %}
</td>
<td>{% if products.product_picture %} <img src="{{products.product_picture.url}}" class="rounded" width="100" height="80" /> {% else %} Not Uploaded {% endif %}</td>
<td>{{products.name}}</td>
<td>
{{products.product_type}}
{% if products.product_type.is_deleted %}
<i class="bi bi-exclamation-triangle text-warning" title="Product type is deleted, please update."></i>
{% endif %}
</td>
<td>
{{products.product_category}}
{% if products.product_category.is_deleted %}
<i class="bi bi-exclamation-triangle text-warning" title="Product category is deleted, please update."></i>
{% endif %}
</td>
<td>
{% if request.user.is_superuser %}
<div class="form-check form-switch">
<input
class="form-check-input"
hx-post="{% url 'products:status' products.id %}"
hx-headers='{"X-CSRFToken":"{{ csrf_token }}"}'
type="checkbox" {% if products.status %} checked {% endif %}
style="cursor: pointer;"
>
</div>
{% else %}
{% if products.status %} Active {% else %} Inactive {% endif %}
{% endif %}
</td>
<td>
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
{% if perms.authentication.view_product %}
<a href="{% url 'products:details_product' products.id %}" class="btn btn-success"><i class="bi bi-eye-fill"></i></a>
{% endif %}
{% if perms.authentication.edit_product %}
<button type="button" class="btn btn-info"
hx-get="{% url 'products:update_product' products.id %}" hx-target="#update-product-modal-content"
data-bs-toggle="modal" data-bs-target="#update-product-modal"
><i class="bi bi-pencil-square"></i></button>
{% endif %}
{% if perms.authentication.delete_product %}
<form action="{% url 'products:delete_product' products.id %}" method="post" onsubmit="return confirm('Are you sure you want to delete this?')">
{% csrf_token %}
<button type="submit" class="btn btn-danger btn-sm"><i class="bi bi-trash3-fill"></i></button>
</form>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
{% else %}
<td colspan="8" class="text-center"> No record found related to your search keyword</td>
{% endif %}