[UPDT] LEAVE: Updated leave module reporting manager permissions by replace template tag is_reportingmanager with is_manager_of
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
{% load i18n %}
|
||||
{% load basefilters %}
|
||||
<div class="oh-btn-group" onclick="event.stopPropagation();">
|
||||
{% if request.user|is_reportingmanager or perms.leave.change_availableleave %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#objectUpdateModal" hx-get="{% url 'available-leave-update' instance.id %}"
|
||||
hx-target="#objectUpdateModalTarget"><ion-icon name="create-outline"></ion-icon></button>
|
||||
{% endif %}
|
||||
{% if request.user|is_reportingmanager or perms.leave.delete_availableleave %}
|
||||
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
|
||||
id="delete-link"
|
||||
hx-get="{% url 'generic-delete' %}?model=leave.AvailableLeave&pk={{instance.id}}"
|
||||
hx-target="#deleteConfirmationBody" data-toggle="oh-modal-toggle"
|
||||
data-target="#deleteConfirmation"
|
||||
>
|
||||
<ion-icon name="trash-outline"></ion-icon></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% 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 %}
|
||||
<div class="oh-btn-group" onclick="event.stopPropagation();">
|
||||
{% if can_manage or can_change %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#objectUpdateModal" hx-get="{% url 'available-leave-update' instance.id %}"
|
||||
hx-target="#objectUpdateModalTarget">
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if can_manage or can_delete %}
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" id="delete-link"
|
||||
hx-get="{% url 'generic-delete' %}?model=leave.AvailableLeave&pk={{instance.id}}"
|
||||
hx-target="#deleteConfirmationBody" data-toggle="oh-modal-toggle" data-target="#deleteConfirmation">
|
||||
<ion-icon name="trash-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{% load i18n %}
|
||||
{% load basefilters %}
|
||||
<div class="oh-btn-group" onclick="event.stopPropagation();">
|
||||
|
||||
{% 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 %}
|
||||
<div class="oh-btn-group" onclick="event.stopPropagation();">
|
||||
{% if instance.status == 'requested' %}
|
||||
<a type="submit"
|
||||
hx-confirm="{% trans 'Are you sure you want to approve ?' %}"
|
||||
@@ -34,5 +34,5 @@
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -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 %}
|
||||
<div class="oh-btn-group" style="width: 100%;">
|
||||
{% if perms.leave.change_compensatoryleaverequest or request.user|is_reportingmanager %}
|
||||
{% if instance.status == 'requested' %}
|
||||
<a type="submit"
|
||||
hx-confirm="{% trans 'Are you sure you want to approve ?' %}"
|
||||
hx-post="{% url 'approve-compensatory-leave' instance.id %}?instances_ids={{request.GET.instance_ids}}"
|
||||
hx-target="#genericModalBody"
|
||||
title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn-group oh-btn--success" style="width: 100%;">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
Approve
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn-group oh-btn--success oh-btn--disabled" style="width: 100%;">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
Approve
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if instance.status == 'requested' or instance.status == 'approved' %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal"
|
||||
hx-get="{% url 'reject-compensatory-leave' instance.id %}"
|
||||
hx-target="#rejectTarget"
|
||||
title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn-group oh-btn--danger w-100">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
Reject
|
||||
{% if instance.status == 'requested' %}
|
||||
<a type="submit" hx-confirm="{% trans 'Are you sure you want to approve ?' %}"
|
||||
hx-post="{% url 'approve-compensatory-leave' instance.id %}?instances_ids={{request.GET.instance_ids}}"
|
||||
hx-target="#genericModalBody" title="{% trans 'Approve' %}" class="oh-btn oh-btn-group oh-btn--success"
|
||||
style="width: 100%;">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
{% trans "Approve" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn-group oh-btn--danger oh-btn--disabled
|
||||
w-100" >
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
Reject
|
||||
<a type="submit" href="#" title="{% trans 'Approve' %}" class="oh-btn oh-btn-group oh-btn--success oh-btn--disabled"
|
||||
style="width: 100%;">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
{% trans "Approve" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if instance.status == 'requested' or instance.status == 'approved' %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle" data-target="#rejectModal"
|
||||
hx-get="{% url 'reject-compensatory-leave' instance.id %}" hx-target="#rejectTarget"
|
||||
title="{% trans 'Reject' %}" class="oh-btn oh-btn-group oh-btn--danger w-100">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
{% trans "Reject" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Reject' %}" class="oh-btn oh-btn-group oh-btn--danger oh-btn--disabled w-100">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
{% trans "Reject" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if request.GET.deleted %}
|
||||
<script>
|
||||
$(".reload-record").click()
|
||||
$("#reloadMessagesButton").click()
|
||||
</script>
|
||||
{% endif %}
|
||||
<script>
|
||||
$(".reload-record").click()
|
||||
$("#reloadMessagesButton").click()
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,37 +1,30 @@
|
||||
{% load i18n %}{% load basefilters %}
|
||||
<div onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group" >
|
||||
|
||||
{% if perms.leave.change_leaveallocationrequest or request.user|is_reportingmanager %}
|
||||
{% if instance.status == 'requested' %}
|
||||
<a type="submit" href="{% url 'leave-allocation-request-approve' instance.id %}"
|
||||
onclick="return confirm('{% trans "Do you want to approve this request?" %}')"
|
||||
title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn--success w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn--success oh-btn--disabled w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if instance.status == 'requested' or instance.status == 'approved' %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal"
|
||||
hx-get="{% url 'leave-allocation-request-reject' instance.id %}"
|
||||
hx-target="#rejectTarget"
|
||||
title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn--danger w-100">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn--danger oh-btn--disabled
|
||||
w-100" >
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% is_manager_of request.user instance as can_manage %}
|
||||
{% if perms.leave.change_leaveallocationrequest or can_manage %}
|
||||
<div onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group">
|
||||
{% if instance.status == 'requested' %}
|
||||
<a type="submit" href="{% url 'leave-allocation-request-approve' instance.id %}"
|
||||
onclick="return confirm('{% trans "Do you want to approve this request?" %}')"
|
||||
title="{% trans 'Approve' %}" class="oh-btn oh-btn--success w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Approve' %}" class="oh-btn oh-btn--success oh-btn--disabled w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if instance.status == 'requested' or instance.status == 'approved' %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle" data-target="#rejectModal"
|
||||
hx-get="{% url 'leave-allocation-request-reject' instance.id %}" hx-target="#rejectTarget"
|
||||
title="{% trans 'Reject' %}" class="oh-btn oh-btn--danger w-100">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Reject' %}" class="oh-btn oh-btn--danger oh-btn--disabled w-100">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,39 +1,32 @@
|
||||
{% load i18n %} {% load basefilters %}
|
||||
{% if perms.leave.Change_leaveallocationrequest or request.user|is_reportingmanager %}
|
||||
{% if instance.status == 'requested' %}
|
||||
<a
|
||||
href="{% url 'leave-allocation-request-approve' instance.id %}"
|
||||
class="oh-btn oh-btn--success w-100"
|
||||
title="{% trans 'Approve' %}" >
|
||||
<ion-icon class="me-1 " name="checkmark-outline"></ion-icon>
|
||||
{% trans "Approve" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="" class="oh-btn oh-btn--success oh-btn--disabled w-100"
|
||||
title="{% trans 'Approved' %}"
|
||||
onclick="event.preventDefault()">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
{% trans "Approve" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if instance.status == 'requested' or instance.status == 'approved' %}
|
||||
<a
|
||||
hx-get="{% url 'leave-allocation-request-reject' instance.id %}"
|
||||
data-target="{% if dashboard == 'true' %}#bigModal {% else %}#rejectModal {% endif %}"
|
||||
hx-target="{% if dashboard == 'true' %}#bigModalTarget {% else %}#rejectTarget{% endif %}"
|
||||
class="oh-btn oh-btn--danger w-100"
|
||||
data-toggle="oh-modal-toggle"
|
||||
title="{% trans 'Reject' %}"
|
||||
>
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
{% trans "Reject" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="" class="oh-btn oh-btn--danger oh-btn--disabled w-100"
|
||||
title="{% trans 'Rejected' %}"
|
||||
onclick="event.preventDefault()">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
{% trans "Reject" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% is_manager_of request.user instance as can_manage %}
|
||||
{% if perms.leave.change_leaveallocationrequest or can_manage %}
|
||||
{% if instance.status == 'requested' %}
|
||||
<a href="{% url 'leave-allocation-request-approve' instance.id %}" class="oh-btn oh-btn--success w-100"
|
||||
title="{% trans 'Approve' %}">
|
||||
<ion-icon class="me-1 " name="checkmark-outline"></ion-icon>
|
||||
{% trans "Approve" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="" class="oh-btn oh-btn--success oh-btn--disabled w-100" title="{% trans 'Approved' %}"
|
||||
onclick="event.preventDefault()">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
{% trans "Approve" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if instance.status == 'requested' or instance.status == 'approved' %}
|
||||
<a hx-get="{% url 'leave-allocation-request-reject' instance.id %}"
|
||||
data-target="{% if dashboard == 'true' %}#bigModal {% else %}#rejectModal {% endif %}"
|
||||
hx-target="{% if dashboard == 'true' %}#bigModalTarget {% else %}#rejectTarget{% endif %}"
|
||||
class="oh-btn oh-btn--danger w-100" data-toggle="oh-modal-toggle" title="{% trans 'Reject' %}">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
{% trans "Reject" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="" class="oh-btn oh-btn--danger oh-btn--disabled w-100" title="{% trans 'Rejected' %}"
|
||||
onclick="event.preventDefault()">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
{% trans "Reject" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,44 +1,50 @@
|
||||
{%load i18n %}
|
||||
{% load i18n %}
|
||||
{% load basefilters %}
|
||||
<div onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group">
|
||||
{% if request.user|is_reportingmanager or perms.attendance.chanage_penaltyaccount or request.user|is_leave_approval_manager %}
|
||||
<button
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#penaltyModal"
|
||||
hx-target="#penaltyModalBody"
|
||||
hx-get="{% url "leave-cut-penalty" instance.id %}"
|
||||
type='submit'
|
||||
class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
|
||||
title="{% trans 'Penalty' %}">
|
||||
<ion-icon name="information-circle-outline"></ion-icon>
|
||||
</button>
|
||||
{% 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' %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#genericModal" hx-get="{% url 'request-update' instance.id %}?instance_ids={{instance.ordered_ids}}"
|
||||
hx-target="#genericModalBody"><ion-icon name="create-outline"></ion-icon></button>
|
||||
{% else %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-50" disabled>
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
</button>
|
||||
{% 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 %}
|
||||
<div onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group">
|
||||
|
||||
{% endif %}
|
||||
{% if instance.status == 'requested' %}
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
|
||||
title="{% trans 'Delete' %}" id="delete-link"
|
||||
hx-confirm="{% trans 'Are you sure you want to delete?' %}"
|
||||
hx-get="{% url 'request-delete' instance.id %}"
|
||||
hx-target="#leaveRequest"
|
||||
>
|
||||
<ion-icon name="trash-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-50" disabled>
|
||||
<ion-icon name="trash-outline"></ion-icon>
|
||||
{# Penalty Button #}
|
||||
{% if can_manage or can_penalty or leave_manager %}
|
||||
<button data-toggle="oh-modal-toggle" data-target="#penaltyModal" hx-target="#penaltyModalBody"
|
||||
hx-get="{% url 'leave-cut-penalty' instance.id %}" type="button"
|
||||
class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" title="{% trans 'Penalty' %}">
|
||||
<ion-icon name="information-circle-outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
{# Edit Button #}
|
||||
{% if can_manage or can_change or leave_manager %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100 {% if instance.status != 'requested' %}disabled{% endif %}"
|
||||
title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle" data-target="#genericModal"
|
||||
{% if instance.status == 'requested' %}
|
||||
hx-get="{% url 'request-update' instance.id %}?instance_ids={{ instance.ordered_ids }}"
|
||||
hx-target="#genericModalBody"
|
||||
{% endif %}
|
||||
>
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
{# Delete Button #}
|
||||
{% if can_manage or can_delete or leave_manager %}
|
||||
<button
|
||||
class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100 {% if instance.status != 'requested' %}disabled{% endif %}"
|
||||
title="{% trans 'Delete' %}"
|
||||
id="delete-link"
|
||||
{% if instance.status == 'requested' %}
|
||||
hx-confirm="{% trans 'Are you sure you want to delete?' %}"
|
||||
hx-get="{% url 'request-delete' instance.id %}"
|
||||
hx-target="#leaveRequest"
|
||||
{% endif %}
|
||||
>
|
||||
<ion-icon name="trash-outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
Reference in New Issue
Block a user