[ADD] DASHBOARD: Leave request and leave allocation request approval from dashboard

This commit is contained in:
Horilla
2024-01-16 11:35:45 +05:30
parent 5833ae287a
commit f5d378d1e5
8 changed files with 349 additions and 48 deletions

View File

@@ -4,6 +4,7 @@ views.py
This module is used to map url patterns with request and approve methods in Dashboard.
"""
from datetime import date
import json
from django.shortcuts import render
from attendance.models import Attendance, AttendanceValidationCondition
@@ -12,6 +13,7 @@ from base.methods import filtersubordinates
from base.models import ShiftRequest, WorkTypeRequest
from employee.not_in_out_dashboard import paginator_qry
from horilla.decorators import login_required
from leave.models import LeaveAllocationRequest, LeaveRequest
@login_required
@@ -82,3 +84,55 @@ def dashboard_attendance_validate(request):
]
)
return render(request, "request_and_approve/attendance_validate.html",{"validate_attendances": validate_attendances,"validate_attendances_ids": validate_attendances_ids, "pd": previous_data,})
@login_required
def leave_request_and_approve(request):
previous_data = request.GET.urlencode()
page_number = request.GET.get("page")
leave_requests = LeaveRequest.objects.filter(status = "requested")
leave_requests = filtersubordinates(
request, leave_requests, "leave.change_leaverequest"
)
leave_requests = paginator_qry(leave_requests, page_number)
leave_requests_ids = json.dumps(
[
instance.id for instance in leave_requests
]
)
return render(
request,
"request_and_approve/leave_request_approve.html",
{
"leave_requests": leave_requests,
"requests_ids": leave_requests_ids,
"pd": previous_data,
# "current_date":date.today(),
}
)
@login_required
def leave_allocation_approve(request):
previous_data = request.GET.urlencode()
page_number = request.GET.get("page")
allocation_reqests = LeaveAllocationRequest.objects.filter(status = "requested")
allocation_reqests = filtersubordinates(
request, allocation_reqests, "leave.view_leaveallocationrequest"
)
# allocation_reqests = paginator_qry(allocation_reqests, page_number)
allocation_reqests_ids = json.dumps(
[
instance.id for instance in allocation_reqests
]
)
return render(
request,
"request_and_approve/leave_allocation_approve.html",
{
"allocation_reqests": allocation_reqests,
"reqests_ids": allocation_reqests_ids,
"pd": previous_data,
# "current_date":date.today(),
}
)

View File

@@ -0,0 +1,75 @@
{% load i18n %}
{% if allocation_reqests %}
<div class="oh-sticky-table">
<div class="oh-sticky-table__table ">
<div class="oh-sticky-table__thead">
<div class="oh-sticky-table__tr">
<div class="oh-sticky-table__th">{% trans "Employee" %}</div>
<div class="oh-sticky-table__th">{% trans "Leave Type" %}</div>
<div class="oh-sticky-table__th">{% trans "Requested Days" %}</div>
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
</div>
</div>
<div class="oh-sticky-table__tbody">
{% for leave_allocation_request in allocation_reqests %}
<div class="oh-sticky-table__tr" draggable="true"
data-toggle="oh-modal-toggle"
data-target="#smallModal"
hx-get="{% url 'leave-allocation-request-single-view' leave_allocation_request.id %}?instances_ids={{reqests_ids}}&dashboard=true"
hx-target="#smallModalTarget">
<div class="oh-sticky-table__sd" >
<div class="oh-profile oh-profile--md">
<div class="oh-profile__avatar mr-1">
{% if leave_allocation_request.employee_id.employee_profile %}
<img src="{{leave_allocation_request.employee_id.get_avatar}}" class="oh-profile__image"
alt="" />
{% else %}
<img src="https://ui-avatars.com/api/?name={{leave_allocation_request.employee_id}}&background=random"
class="oh-profile__image" alt="" />
{% endif %}
</div>
<span class="oh-profile__name oh-text--dark">{{leave_allocation_request.employee_id}}</span>
</div>
</div>
<div class="oh-sticky-table__td">{{leave_allocation_request.leave_type_id}}</div>
<div class="oh-sticky-table__td">{{leave_allocation_request.requested_days}}</div>
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
<div class="oh-btn-group">
{% if leave_allocation_request.status == 'requested' %}
<a type="submit" href="{% url 'leave-allocation-request-approve' leave_allocation_request.id %}"
title="{% trans 'Approve' %}"
class="oh-btn oh-btn--success w-100">
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
</a>
{% endif %}
{% if leave_allocation_request.status == 'requested' or leave_allocation_request.status == 'approved' %}
<a type="submit" data-toggle="oh-modal-toggle"
data-target="#bigModal"
hx-get="{% url 'leave-allocation-request-reject' leave_allocation_request.id %}"
hx-target="#bigModalTarget"
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>
</div>
{% endfor %}
</div>
</div>
</div>
{% else %}
<div style="height: 380px; display:flex;align-items: center;justify-content: center;" class="">
<div style="" class="">
<img style="display: block;width: 70px;margin: 20px auto ;" src="/static/images/ui/joiningchart.png" class="" alt=""/>
<h3 style="font-size:16px" class="oh-404__subtitle">{% trans "No data Found..." %}</h3>
</div>
</div>
{% endif %}

View File

@@ -0,0 +1,53 @@
{% load i18n %}
{% if leave_requests %}
<div class="oh-sticky-table">
<div class="oh-sticky-table__table ">
<div class="oh-sticky-table__thead">
<div class="oh-sticky-table__tr">
<div class="oh-sticky-table__th">{% trans "Employee" %}</div>
<div class="oh-sticky-table__th">{% trans "Start Date" %}</div>
<div class="oh-sticky-table__th">{% trans "End Date" %}</div>
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
</div>
</div>
<div class="oh-sticky-table__tbody">
{% for leave_request in leave_requests %}
<div class="oh-sticky-table__tr" draggable="true" data-toggle="oh-modal-toggle" data-target="#bigModal"
hx-get="{% url 'one-request-view' leave_request.id %}?instances_ids={{requests_ids}}&dashboard=true" hx-target="#bigModalTarget">
<div class="oh-sticky-table__td">
<div class="oh-profile oh-profile--md">
<div class="oh-profile__avatar mr-1">
<img src="{{leave_request.employee_id.get_avatar}}" class="oh-profile__image"
alt="" />
</div>
<span class="oh-profile__name oh-text--dark">{{leave_request.employee_id}}</span>
</div>
</div>
<div class="oh-sticky-table__td dateformat_changer">{{leave_request.start_date}}</div>
<div class="oh-sticky-table__td dateformat_changer">{{leave_request.end_date}}</div>
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
<div class="oh-btn-group" >
<a type="submit" href="{% url 'request-approve' leave_request.id %}" title="{% trans 'Approve' %}"
class="oh-btn oh-btn--success w-100">
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
</a>
<a type="submit" data-toggle="oh-modal-toggle"
data-target="#bigModal" hx-get="{% url 'request-cancel' leave_request.id %}" hx-target="#bigModalTarget" title="{% trans 'Reject' %}"
class="oh-btn oh-btn--danger w-100">
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% else %}
<div style="height: 380px; display:flex;align-items: center;justify-content: center;" class="">
<div style="" class="">
<img style="display: block;width: 70px;margin: 20px auto ;" src="/static/images/ui/joiningchart.png" class="" alt=""/>
<h3 style="font-size:16px" class="oh-404__subtitle">{% trans "No data Found..." %}</h3>
</div>
</div>
{% endif %}

View File

@@ -1,5 +1,6 @@
from django.urls import path
from base import request_and_approve, views
from base.forms import RotatingShiftAssignForm, RotatingWorkTypeAssignForm, RotatingWorkTypeForm
from base.models import (
Company,
Department,
@@ -9,7 +10,9 @@ from base.models import (
JobPosition,
JobRole,
RotatingShift,
RotatingShiftAssign,
RotatingWorkType,
RotatingWorkTypeAssign,
WorkType,
)
from django.contrib.auth.models import Group
@@ -83,7 +86,7 @@ urlpatterns = [
views.mail_server_create_or_update,
name="mail-server-create-update",
),
path("mail-server-delete",views.mail_server_delete,name="mail-server-delete"),
path("mail-server-delete", views.mail_server_delete, name="mail-server-delete"),
path("settings/company-create/", views.company_create, name="company-create"),
path("settings/company-view/", views.company_view, name="company-view"),
path(
@@ -216,6 +219,16 @@ urlpatterns = [
views.rotating_work_type_assign_update,
name="rotating-work-type-assign-update",
),
path(
"rotating-work-type-assign-duplicate/<int:obj_id>/",
views.object_duplicate,
name="rotating-work-type-assign-duplicate",
kwargs={
"model": RotatingWorkTypeAssign,
"form": RotatingWorkTypeAssignForm,
"template": "base/rotating_work_type/htmx/rotating_work_type_assign_form.html",
},
),
path(
"rotating-work-type-assign-archive/<int:id>/",
views.rotating_work_type_assign_archive,
@@ -361,6 +374,16 @@ urlpatterns = [
views.rotating_shift_assign_update,
name="rotating-shift-assign-update",
),
path(
"rotating-shift-assign-duplicate/<int:obj_id>/",
views.object_duplicate,
name="rotating-shift-assign-duplicate",
kwargs={
"model": RotatingShiftAssign,
"form": RotatingShiftAssignForm,
"template": "base/rotating_shift/htmx/rotating_shift_assign_form.html",
},
),
path(
"rotating-shift-assign-archive/<int:id>/",
views.rotating_shift_assign_archive,
@@ -559,47 +582,39 @@ urlpatterns = [
views.rotating_work_type_select_filter,
name="r-work-type-select-filter",
),
path("settings/ticket-type-view/", views.ticket_type_view, name="ticket-type-view"),
path("ticket-type-create", views.ticket_type_create, name="ticket-type-create"),
path(
"settings/ticket-type-view/",views.ticket_type_view,name="ticket-type-view"
"ticket-type-update/<int:t_type_id>",
views.ticket_type_update,
name="ticket-type-update",
),
path(
"ticket-type-create",views.ticket_type_create,name="ticket-type-create"
"ticket-type-delete/<int:t_type_id>",
views.ticket_type_delete,
name="ticket-type-delete",
),
path("settings/tag-view/", views.tag_view, name="tag-view"),
path("tag-create", views.tag_create, name="tag-create"),
path("tag-update/<int:tag_id>", views.tag_update, name="tag-update"),
path("tag-delete/<int:tag_id>", views.tag_delete, name="tag-delete"),
path("employee-tag-create", views.employee_tag_create, name="employee-tag-create"),
path(
"employee-tag-update/<int:tag_id>",
views.employee_tag_update,
name="employee-tag-update",
),
path(
"ticket-type-update/<int:t_type_id>",views.ticket_type_update,name="ticket-type-update"
"employee-tag-delete/<int:tag_id>",
views.employee_tag_delete,
name="employee-tag-delete",
),
path("audit-tag-create", views.audit_tag_create, name="audit-tag-create"),
path(
"audit-tag-update/<int:tag_id>", views.audit_tag_update, name="audit-tag-update"
),
path(
"ticket-type-delete/<int:t_type_id>",views.ticket_type_delete,name="ticket-type-delete"
),
path(
"settings/tag-view/",views.tag_view,name="tag-view"
),
path(
"tag-create",views.tag_create,name="tag-create"
),
path(
"tag-update/<int:tag_id>",views.tag_update,name="tag-update"
),
path(
"tag-delete/<int:tag_id>",views.tag_delete,name="tag-delete"
),
path(
"employee-tag-create",views.employee_tag_create,name="employee-tag-create"
),
path(
"employee-tag-update/<int:tag_id>",views.employee_tag_update,name="employee-tag-update"
),
path(
"employee-tag-delete/<int:tag_id>",views.employee_tag_delete,name="employee-tag-delete"
),
path(
"audit-tag-create",views.audit_tag_create,name="audit-tag-create"
),
path(
"audit-tag-update/<int:tag_id>",views.audit_tag_update,name="audit-tag-update"
),
path(
"audit-tag-delete/<int:tag_id>",views.audit_tag_delete,name="audit-tag-delete"
"audit-tag-delete/<int:tag_id>", views.audit_tag_delete, name="audit-tag-delete"
),
path(
"configuration/multiple-approval-condition",
@@ -636,7 +651,7 @@ urlpatterns = [
views.delete_shiftrequest_comment,
name="shift-request-delete-comment",
),
path(
path(
"worktype-request-add-comment/<int:worktype_id>/",
views.create_worktyperequest_comment,
name="worktype-request-add-comment",
@@ -671,6 +686,14 @@ urlpatterns = [
request_and_approve.dashboard_attendance_validate,
name="dashboard-attendance-validate",
),
path(
"leave-request-and-approve",
request_and_approve.leave_request_and_approve,
name="leave-request-and-approve",
),
path(
"leave-allocation-approve",
request_and_approve.leave_allocation_approve,
name="leave-allocation-approve",
),
]