From a5729b7ddd4edd48323c5f7360d74d6d67b95a81 Mon Sep 17 00:00:00 2001 From: Horilla Date: Thu, 27 Nov 2025 16:30:23 +0530 Subject: [PATCH] [UPDT] LEAVE: Updated leave module reporting manager permissions by replace template tag is_reportingmanager with is_manager_of --- leave/cbv/leave_requests.py | 6 +- .../assigned_leave_actions.html | 38 ++++---- .../compensatory_confirmation.html | 10 +-- .../compensatory_detail_actions.html | 72 +++++++--------- .../confirmations.html | 59 ++++++------- .../leave_detail_action.html | 69 +++++++-------- .../cbv/leave_requests/actions_col.html | 86 ++++++++++--------- 7 files changed, 165 insertions(+), 175 deletions(-) diff --git a/leave/cbv/leave_requests.py b/leave/cbv/leave_requests.py index 5f4a9e0b6..fca0740d1 100644 --- a/leave/cbv/leave_requests.py +++ b/leave/cbv/leave_requests.py @@ -17,7 +17,7 @@ from django.utils.translation import gettext_lazy as _ from base.cbv.penalty import ViewPenaltyList from base.decorators import manager_can_enter from base.filters import PenaltyFilter -from base.methods import choosesubordinates, filtersubordinates +from base.methods import choosesubordinates, filtersubordinates, is_reportingmanager from base.models import PenaltyAccounts from horilla_views.cbv_methods import login_required from horilla_views.generic.cbv.views import ( @@ -243,7 +243,9 @@ class LeaveRequestsNavView(HorillaNavView): }, ] - if self.request.user.has_perm("leave.add_leaverequest"): + if self.request.user.has_perm("leave.add_leaverequest") or is_reportingmanager( + self.request + ): self.create_attrs = f""" hx-get="{reverse_lazy("request-creation")}" hx-target="#genericModalBody" diff --git a/leave/templates/cbv/assigned_leave/assigned_leave_actions.html b/leave/templates/cbv/assigned_leave/assigned_leave_actions.html index b84dfb774..ac824db77 100644 --- a/leave/templates/cbv/assigned_leave/assigned_leave_actions.html +++ b/leave/templates/cbv/assigned_leave/assigned_leave_actions.html @@ -1,19 +1,23 @@ {% load i18n %} {% load basefilters %} -
- {% if request.user|is_reportingmanager or perms.leave.change_availableleave %} - - {% endif %} - {% if request.user|is_reportingmanager or perms.leave.delete_availableleave %} - - - - {% endif %} -
+{% is_manager_of request.user instance as can_manage %} +{% with can_change=perms.leave.change_availableleave can_delete=perms.leave.delete_availableleave %} +{% if can_change or can_delete or can_manage %} +
+ {% if can_manage or can_change %} + + {% endif %} + {% if can_manage or can_delete %} + + + + {% endif %} +
+{% endif %} +{% endwith %} diff --git a/leave/templates/cbv/compensatory_leave/compensatory_confirmation.html b/leave/templates/cbv/compensatory_leave/compensatory_confirmation.html index 9d060124f..90247a5a8 100644 --- a/leave/templates/cbv/compensatory_leave/compensatory_confirmation.html +++ b/leave/templates/cbv/compensatory_leave/compensatory_confirmation.html @@ -1,8 +1,8 @@ {% load i18n %} {% load basefilters %} -
- - {% if perms.leave.change_leaveallocationrequest or request.user|is_reportingmanager %} +{% is_manager_of request.user instance as can_manage %} +{% if perms.leave.change_leaveallocationrequest or can_manage %} +
{% if instance.status == 'requested' %} {% endif %} - {% endif %} -
+
+{% endif %} diff --git a/leave/templates/cbv/compensatory_leave/compensatory_detail_actions.html b/leave/templates/cbv/compensatory_leave/compensatory_detail_actions.html index 4ac15ddcd..c2006cb8e 100644 --- a/leave/templates/cbv/compensatory_leave/compensatory_detail_actions.html +++ b/leave/templates/cbv/compensatory_leave/compensatory_detail_actions.html @@ -1,51 +1,43 @@ {% load i18n %} {% load basefilters %} - - +{% is_manager_of request.user instance as can_manage %} +{% if perms.leave.change_compensatoryleaverequest or can_manage %}
- {% if perms.leave.change_compensatoryleaverequest or request.user|is_reportingmanager %} - {% if instance.status == 'requested' %} - - - Approve - - {% else %} - - - Approve - - {% endif %} - {% if instance.status == 'requested' or instance.status == 'approved' %} - - - Reject + {% if instance.status == 'requested' %} + + + {% trans "Approve" %} {% else %} - - - Reject + + + {% trans "Approve" %} {% endif %} + {% if instance.status == 'requested' or instance.status == 'approved' %} + + + {% trans "Reject" %} + + {% else %} + + + {% trans "Reject" %} + {% endif %} -
+ +{% endif %} {% if request.GET.deleted %} - - {% endif %} + +{% endif %} diff --git a/leave/templates/cbv/leave_allocation_request/confirmations.html b/leave/templates/cbv/leave_allocation_request/confirmations.html index 7ca212c67..082172fb9 100644 --- a/leave/templates/cbv/leave_allocation_request/confirmations.html +++ b/leave/templates/cbv/leave_allocation_request/confirmations.html @@ -1,37 +1,30 @@ {% load i18n %}{% load basefilters %} -
-
- - {% if perms.leave.change_leaveallocationrequest or request.user|is_reportingmanager %} - {% if instance.status == 'requested' %} - - - - {% else %} - - - - {% endif %} - {% if instance.status == 'requested' or instance.status == 'approved' %} - - - - {% else %} - - - - {% endif %} +{% is_manager_of request.user instance as can_manage %} +{% if perms.leave.change_leaveallocationrequest or can_manage %} +
+
+ {% if instance.status == 'requested' %} + + + + {% else %} + + + + {% endif %} + {% if instance.status == 'requested' or instance.status == 'approved' %} + + + + {% else %} + + + {% endif %}
+{% endif %} diff --git a/leave/templates/cbv/leave_allocation_request/leave_detail_action.html b/leave/templates/cbv/leave_allocation_request/leave_detail_action.html index 538996979..76b4ba9af 100644 --- a/leave/templates/cbv/leave_allocation_request/leave_detail_action.html +++ b/leave/templates/cbv/leave_allocation_request/leave_detail_action.html @@ -1,39 +1,32 @@ {% load i18n %} {% load basefilters %} -{% if perms.leave.Change_leaveallocationrequest or request.user|is_reportingmanager %} - {% if instance.status == 'requested' %} - - - {% trans "Approve" %} - - {% else %} - - - {% trans "Approve" %} - - {% endif %} - {% if instance.status == 'requested' or instance.status == 'approved' %} - - - {% trans "Reject" %} - - {% else %} - - - {% trans "Reject" %} - - {% endif %} - {% endif %} +{% is_manager_of request.user instance as can_manage %} +{% if perms.leave.change_leaveallocationrequest or can_manage %} + {% if instance.status == 'requested' %} + + + {% trans "Approve" %} + + {% else %} + + + {% trans "Approve" %} + + {% endif %} + {% if instance.status == 'requested' or instance.status == 'approved' %} + + + {% trans "Reject" %} + + {% else %} + + + {% trans "Reject" %} + + {% endif %} +{% endif %} diff --git a/leave/templates/cbv/leave_requests/actions_col.html b/leave/templates/cbv/leave_requests/actions_col.html index 843229ed4..d59e292b1 100644 --- a/leave/templates/cbv/leave_requests/actions_col.html +++ b/leave/templates/cbv/leave_requests/actions_col.html @@ -1,44 +1,50 @@ -{%load i18n %} +{% load i18n %} {% load basefilters %} -
-
- {% if request.user|is_reportingmanager or perms.attendance.chanage_penaltyaccount or request.user|is_leave_approval_manager %} - - {% endif %} - {% if request.user|is_reportingmanager or perms.leave.change_leaverequest or perms.leave.delete_leaverequest or request.user|is_leave_approval_manager %} - {% if instance.status == 'requested' %} - - {% else %} - +{% is_manager_of request.user instance as can_manage %} +{% with can_change=perms.leave.change_leaverequest can_delete=perms.leave.delete_leaverequest can_penalty=perms.base.chanage_penaltyaccounts leave_manager=request.user|is_leave_approval_manager %} +{% if can_change or can_delete or can_penalty or can_manage or leave_manager %} +
+
- {% endif %} - {% if instance.status == 'requested' %} - - - - {% else %} - + {% endif %} + + {# Edit Button #} + {% if can_manage or can_change or leave_manager %} + + {% endif %} + + {# Delete Button #} + {% if can_manage or can_delete or leave_manager %} + - {% endif %} - {% endif %} + {% endif %} + +
-
+{% endif %} +{% endwith %}