[UPDT] HORILLA: Permission updations in views

This commit is contained in:
Horilla
2025-12-03 14:50:33 +05:30
parent d0fb75442b
commit 6ede82ce60
17 changed files with 200 additions and 169 deletions

View File

@@ -10,7 +10,7 @@ from horilla_views.generic.cbv.views import HorillaDetailedView, HorillaListView
@method_decorator(login_required, name="dispatch")
@method_decorator(permission_required("asset.view_assetlot"), name="dispatch")
@method_decorator(permission_required("asset.view_asset"), name="dispatch")
class AssetListView(HorillaListView):
"""
list view for batch number

View File

@@ -40,7 +40,7 @@
{% endif %}
{% endif %}
{% if perms.asset.add_asset %}
{% if perms.asset.change_asset %}
<a
class="oh-btn oh-btn--light-bkg w-100 flex-1"
data-toggle="oh-modal-toggle"

View File

@@ -4,7 +4,7 @@
{% if instance.asset_request_status == 'Requested' %}
<div class="oh-btn-group">
<a
class="oh-btn oh-btn--success w-100"
class="oh-btn oh-btn--success w-50"
role="button123"
data-toggle="oh-modal-toggle"
data-target="#objectCreateModal"

View File

@@ -2,60 +2,63 @@
<div>
<div class="oh-btn-group">
{% if instance.asset_request_status == "Approved" %}
<a
class="oh-btn oh-btn--light-bkg oh-btn--disabled w-100"
title="{% trans 'Edit' %}"
>
<ion-icon
name="create-outline"
role="img"
class="md hydrated"
aria-label="create outline"
></ion-icon>
</a>
{% else %}
<a
class="oh-btn oh-btn--light-bkg w-100"
title="{% trans 'Edit' %}"
data-toggle="oh-modal-toggle"
data-target="#genericModal"
hx-put="{% url 'asset-request-update' instance.id %}"
hx-target="#genericModalBody"
>
<ion-icon
name="create-outline"
role="img"
class="md hydrated"
aria-label="create outline"
></ion-icon>
</a>
{% if perms.asset.change_assetrequest or request.user.employee_get == instance.requested_employee_id %}
{% if instance.asset_request_status == "Approved" %}
<a
class="oh-btn oh-btn--light-bkg oh-btn--disabled w-100"
title="{% trans 'Edit' %}"
>
<ion-icon
name="create-outline"
role="img"
class="md hydrated"
aria-label="create outline"
></ion-icon>
</a>
{% else %}
<a
class="oh-btn oh-btn--light-bkg w-100"
title="{% trans 'Edit' %}"
data-toggle="oh-modal-toggle"
data-target="#genericModal"
hx-put="{% url 'asset-request-update' instance.id %}"
hx-target="#genericModalBody"
>
<ion-icon
name="create-outline"
role="img"
class="md hydrated"
aria-label="create outline"
></ion-icon>
</a>
{% endif %}
{% endif %}
{% if instance.asset_request_status == "Approved" %}
<a
class="oh-btn oh-btn--light-bkg oh-btn--danger-outline oh-btn--disabled w-100"
title="{% trans 'Delete' %}"
>
<ion-icon
name="trash-outline"
role="img"
class="md hydrated"
></ion-icon>
</a>
{% else %}
<a
class="oh-btn oh-btn--light-bkg oh-btn--danger-outline w-100"
title="{% trans 'Delete' %}"
hx-confirm="{% trans 'Do you want to delete this Allocation?' %}"
hx-post="{% url 'asset-request-delete' instance.id %}"
>
<ion-icon
name="trash-outline"
role="img"
class="md hydrated"
></ion-icon>
</a>
{% if perms.asset.delete_assetrequest %}
{% if instance.asset_request_status == "Approved" %}
<a
class="oh-btn oh-btn--light-bkg oh-btn--danger-outline oh-btn--disabled w-100"
title="{% trans 'Delete' %}"
>
<ion-icon
name="trash-outline"
role="img"
class="md hydrated"
></ion-icon>
</a>
{% else %}
<a
class="oh-btn oh-btn--light-bkg oh-btn--danger-outline w-100"
title="{% trans 'Delete' %}"
hx-confirm="{% trans 'Do you want to delete this Allocation?' %}"
hx-post="{% url 'asset-request-delete' instance.id %}"
>
<ion-icon
name="trash-outline"
role="img"
class="md hydrated"
></ion-icon>
</a>
{% endif %}
{% endif %}
</div>
</div>