Merge master
This commit is contained in:
@@ -193,6 +193,18 @@ class AttendanceRequestListTab(AttendancesRequestListView):
|
||||
return queryset
|
||||
|
||||
|
||||
def change_accessibility(request, instance: object = None, *args, **kwargs) -> bool:
|
||||
|
||||
if (
|
||||
request.user.has_perm("attendance.change_attendance")
|
||||
or is_reportingmanager(request)
|
||||
or request.user == instance.employee_id.employee_user_id
|
||||
):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
class AttendanceListTab(AttendancesRequestListView):
|
||||
"""
|
||||
@@ -219,6 +231,7 @@ class AttendanceListTab(AttendancesRequestListView):
|
||||
{
|
||||
"action": _("Edit"),
|
||||
"icon": "create-outline",
|
||||
"accessibility": "attendance.cbv.attendance_request.change_accessibility",
|
||||
"attrs": """
|
||||
class="oh-btn oh-btn--light-bkg w-100"
|
||||
data-toggle="oh-modal-toggle"
|
||||
@@ -334,21 +347,29 @@ class AttendanceListTabDetailView(HorillaDetailedView):
|
||||
(_("Activities"), "attendance_detail_activity_col", True),
|
||||
]
|
||||
|
||||
actions = [
|
||||
{
|
||||
"action": _("Edit"),
|
||||
"icon": "create-outline",
|
||||
"attrs": """
|
||||
onclick="event.stopPropagation();"
|
||||
class="oh-btn oh-btn--info w-100"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#genericModalEdit"
|
||||
hx-get="{change_attendance}?all_attendance=true"
|
||||
hx-target="#genericModalEditBody"
|
||||
def get_context_data(self, **kwargs):
|
||||
if (
|
||||
self.request.user.has_perm("attendance.change_attendance")
|
||||
or is_reportingmanager(self.request)
|
||||
or self.request.user == self.get_object().employee_id.employee_user_id
|
||||
):
|
||||
|
||||
""",
|
||||
}
|
||||
]
|
||||
self.actions = [
|
||||
{
|
||||
"action": _("Edit"),
|
||||
"icon": "create-outline",
|
||||
"attrs": """
|
||||
onclick="event.stopPropagation();"
|
||||
class="oh-btn oh-btn--info w-100"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#genericModalEdit"
|
||||
hx-get="{change_attendance}?all_attendance=true"
|
||||
hx-target="#genericModalEditBody"
|
||||
|
||||
""",
|
||||
}
|
||||
]
|
||||
return super().get_context_data(**kwargs)
|
||||
|
||||
|
||||
class NewAttendanceRequestFormView(HorillaFormView):
|
||||
|
||||
@@ -171,3 +171,20 @@ def history_accessibility(
|
||||
) or check_manager(request.user.employee_get, instance):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def project_accessibility(
|
||||
request, instance: object = None, user_perms: PermWrapper = [], *args, **kwargs
|
||||
) -> bool:
|
||||
"""
|
||||
permission for work type and shift tab in employee profile
|
||||
"""
|
||||
employee = Employee.objects.get(id=instance.pk)
|
||||
check_manages = check_manager(request.user.employee_get, instance)
|
||||
if (
|
||||
request.user == employee.employee_user_id
|
||||
or check_manages
|
||||
or request.user.has_perm("project.view_project")
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -1,29 +1,54 @@
|
||||
{% load i18n %} {% load basefilters %}
|
||||
<div class="oh-btn-group" style="width: 100%">
|
||||
{% if request.user|is_reportingmanager or perms.leave.change_availableleave %}
|
||||
<a
|
||||
hx-get="{% url 'available-leave-update' instance.id %}"
|
||||
hx-target="#objectUpdateModalTarget"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#objectUpdateModal"
|
||||
class="oh-btn oh-btn--info w-50"
|
||||
>
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
{% trans 'Edit' %}
|
||||
</a>
|
||||
{% if request.user|is_reportingmanager or perms.leave.change_availableleave and perms.leave.delete_availableleave %}
|
||||
<a
|
||||
hx-get="{% url 'available-leave-update' instance.id %}"
|
||||
hx-target="#objectUpdateModalTarget"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#objectUpdateModal"
|
||||
class="oh-btn oh-btn--info w-50"
|
||||
>
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
{% trans 'Edit' %}
|
||||
</a>
|
||||
<button
|
||||
class="oh-btn oh-btn-group oh-btn--secondary"
|
||||
hx-confirm="{% trans 'Are you sure you want to delete this assigned leave request?' %}"
|
||||
id="deletebtn"
|
||||
hx-post="{% url 'assign-delete' instance.id %}?instances_ids={{request.GET.instance_ids}}"
|
||||
hx-target="#genericModalBody"
|
||||
style="width: 50%"
|
||||
data-toggle="oh-modal-toggle"
|
||||
>
|
||||
<ion-icon class="me-1" name="trash-outline"></ion-icon>
|
||||
{% trans 'Delete' %}
|
||||
</button>
|
||||
{% elif request.user|is_reportingmanager or perms.leave.change_availableleave %}
|
||||
<a
|
||||
hx-get="{% url 'available-leave-update' instance.id %}"
|
||||
hx-target="#objectUpdateModalTarget"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#objectUpdateModal"
|
||||
class="oh-btn oh-btn--info w-100"
|
||||
>
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
{% trans 'Edit' %}
|
||||
</a>
|
||||
{% elif request.user|is_reportingmanager or perms.leave.delete_availableleave %}
|
||||
<button
|
||||
class="oh-btn oh-btn-group oh-btn--secondary"
|
||||
hx-confirm="{% trans 'Are you sure you want to delete this assigned leave request?' %}"
|
||||
id="deletebtn"
|
||||
hx-post="{% url 'assign-delete' instance.id %}?instances_ids={{request.GET.instance_ids}}"
|
||||
hx-target="#genericModalBody"
|
||||
style="width:100%"
|
||||
data-toggle="oh-modal-toggle"
|
||||
>
|
||||
<ion-icon class="me-1" name="trash-outline"></ion-icon>
|
||||
{% trans 'Delete' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
<button
|
||||
class="oh-btn oh-btn-group oh-btn--secondary"
|
||||
hx-confirm="{% trans 'Are you sure you want to delete this assigned leave request?' %}"
|
||||
id="deletebtn"
|
||||
hx-post="{% url 'assign-delete' instance.id %}?instances_ids={{request.GET.instance_ids}}"
|
||||
hx-target="#genericModalBody"
|
||||
style="width: 50%"
|
||||
data-toggle="oh-modal-toggle"
|
||||
>
|
||||
<ion-icon class="me-1" name="trash-outline"></ion-icon>
|
||||
{% trans 'Delete' %}
|
||||
</button>
|
||||
|
||||
</div>
|
||||
{% if request.GET.deleted %}
|
||||
<script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% load i18n %}
|
||||
{% load i18n %} {% load basefilters %}
|
||||
<div class="oh-modal__button-container text-center mt-3 w-100">
|
||||
<div class="oh-btn oh-btn-group">
|
||||
{% if instance.is_approved and instance.status == 'requested' %}
|
||||
{% if instance.is_approved and instance.status == 'requested' and perms.leave.change_leaverequest or request.user|is_reportingmanager %}
|
||||
{% if instance.employee_id == request.user.employee_get and not request.user.is_superuser %}
|
||||
<a type="submit" href="#" title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn-group oh-btn--success oh-btn--disabled
|
||||
@@ -21,15 +21,22 @@
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
<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--info w-100"
|
||||
title="Penalty" id="penaltyButton">
|
||||
<ion-icon name="information-circle-outline" role="img" class="md hydrated" aria-label="information circle outline"></ion-icon>
|
||||
</button>
|
||||
{% if instance.status != 'rejected' and instance.end_date >= current_date %}
|
||||
{% if perms.leave.change_leaverequest or request.user|is_reportingmanager %}
|
||||
<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--info w-100"
|
||||
title="Penalty" id="penaltyButton">
|
||||
<ion-icon name="information-circle-outline" role="img" class="md hydrated" aria-label="information circle outline"></ion-icon>
|
||||
</button>
|
||||
{% else %}
|
||||
<button type="submit" class="oh-btn oh-btn-group oh-btn--info oh-btn--disabled w-100"
|
||||
title="Penalty" id="penaltyButton">
|
||||
<ion-icon name="information-circle-outline" role="img" class="md hydrated" aria-label="information circle outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if instance.status != 'rejected' and instance.end_date >= current_date and perms.leave.change_leaverequest or request.user|is_reportingmanager %}
|
||||
{% comment %} {% if instance.status != 'cancelled' %} {% endcomment %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal" hx-get="{% url 'request-cancel' instance.id %}" hx-target="#rejectForm" title="{% trans 'Reject' %}"
|
||||
|
||||
@@ -521,7 +521,7 @@ EmployeeProfileView.add_tab(
|
||||
"title": "Projects",
|
||||
# "view": projects_tab,
|
||||
"view": ProjectsTabView.as_view(),
|
||||
"accessibility": "employee.cbv.accessibility.workshift_accessibility",
|
||||
"accessibility": "employee.cbv.accessibility.project_accessibility",
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user