From f7b92b152ee5ea96c52002344e85baf27b86098d Mon Sep 17 00:00:00 2001 From: Horilla Date: Wed, 27 Aug 2025 16:16:38 +0530 Subject: [PATCH] [FIX] OFFBOARDING: Fixed the offboarding dashboard missing urls and functions --- offboarding/cbv/exit_process.py | 133 ++++++++++++++++++++++++++++++++ offboarding/urls.py | 15 ++++ 2 files changed, 148 insertions(+) diff --git a/offboarding/cbv/exit_process.py b/offboarding/cbv/exit_process.py index 9823cdd65..fe45ac486 100644 --- a/offboarding/cbv/exit_process.py +++ b/offboarding/cbv/exit_process.py @@ -6,6 +6,7 @@ import re from datetime import datetime, timedelta from django import forms +from django.apps import apps from django.contrib import messages from django.http import HttpResponse from django.urls import reverse, reverse_lazy @@ -14,6 +15,7 @@ from django.utils.translation import gettext_lazy as _ from base.context_processors import intial_notice_period from base.methods import eval_validate +from horilla.methods import get_horilla_model_class from horilla_views.cbv_methods import login_required, permission_required from horilla_views.generic.cbv.kanban import HorillaKanbanView from horilla_views.generic.cbv.pipeline import Pipeline @@ -787,3 +789,134 @@ class OffboardingEmployeeList(HorillaListView): employee_id__in=instance_ids, task_id=pk ).update(status=status) return response + + +@method_decorator(login_required, name="dispatch") +class DashboardTaskListview(HorillaListView): + """ + For dashboard task status table + """ + + # view_id = "view-container" + + model = OffboardingEmployee + filter_class = PipelineEmployeeFilter + bulk_select_option = False + view_id = "dashboard_task_status" + + def get_queryset(self): + """ + Returns a filtered queryset of records assigned to a specific employee + """ + + qs = OffboardingEmployee.objects.entire() + queryset = super().get_queryset(queryset=qs) + return queryset + + columns = [ + ("Employee", "employee_id", "employee_id__get_avatar"), + ("Stage", "stage_id"), + ("Task Status", "get_task_status_col"), + ] + + +if apps.is_installed("asset"): + + @method_decorator(login_required, name="dispatch") + @method_decorator( + any_manager_can_enter("offboarding.view_offboarding"), name="dispatch" + ) + class DashboardNotReturndAsssets(HorillaListView): + """ + For dashboard task status table + """ + + bulk_select_option = False + view_id = "dashboard_task_status" + + def __init__(self, *args, **kwargs): + self.AssetAssignment = get_horilla_model_class( + app_label="asset", model="assetassignment" + ) + self.model = self.AssetAssignment # 809 + super().__init__(*args, **kwargs) + + def get_queryset(self): + """ + Returns a filtered queryset of records assigned to a specific employee + """ + + offboarding_employees = OffboardingEmployee.objects.entire().values_list( + "employee_id__id", flat=True + ) + qs = self.model.objects.entire().filter( + return_status__isnull=True, + assigned_to_employee_id__in=offboarding_employees, + ) + queryset = ( + super().get_queryset().filter(id__in=qs.values_list("id", flat=True)) + ) + return queryset + + columns = [ + ( + "Employee", + "assigned_to_employee_id__get_full_name", + "assigned_to_employee_id__get_avatar", + ), + ("Asset", "asset_id__asset_name"), + ("Reminder", "get_send_mail_employee_link"), + ] + + row_attrs = """ + onclick=" + localStorage.setItem('activeTabAsset','#tab_2'); + window.location.href='{get_asset_of_offboarding_employee}'" + """ + + +if apps.is_installed("pms"): + + @method_decorator(login_required, name="dispatch") + @method_decorator( + any_manager_can_enter("offboarding.view_offboarding"), name="dispatch" + ) + class DashboardFeedbackView(HorillaListView): + """ + For dashboard task status table + """ + + bulk_select_option = False + view_id = "dashboard_task_status" + columns = [ + ("Employee", "employee_id__get_full_name", "employee_id__get_avatar"), + ("Feedback", "review_cycle"), + ("Status", "status"), + ] + + def __init__(self, *args, **kwargs): + self.Feedback = get_horilla_model_class(app_label="pms", model="feedback") + self.model = self.Feedback # 809 + super().__init__(*args, **kwargs) + + def get_queryset(self): + """ + Returns a filtered queryset of records assigned to a specific employee + """ + offboarding_employees = OffboardingEmployee.objects.entire().values_list( + "employee_id__id", "notice_period_starts" + ) + if offboarding_employees: + id_list, date_list = map(list, zip(*offboarding_employees)) + else: + id_list, date_list = [], [] + + qs = ( + self.model.objects.entire() + .filter(employee_id__in=id_list) + .exclude(status="Closed") + ) + queryset = ( + super().get_queryset().filter(id__in=qs.values_list("id", flat=True)) + ) + return queryset diff --git a/offboarding/urls.py b/offboarding/urls.py index 25c057970..9fb69aff9 100644 --- a/offboarding/urls.py +++ b/offboarding/urls.py @@ -261,6 +261,11 @@ urlpatterns = [ views.dashboard_join_chart, name="dashboard-join-chart", ), + path( + "list-dashboard-task-status/", + exit_process.DashboardTaskListview.as_view(), + name="list-dashboard-task-status", + ), ] if apps.is_installed("asset"): @@ -270,6 +275,11 @@ if apps.is_installed("asset"): views.dashboard_asset_table, name="dashboard-asset-table", ), + path( + "dashboard-asset-table-cbv", + exit_process.DashboardNotReturndAsssets.as_view(), + name="dashboard-asset-table-cbv", + ), ] if apps.is_installed("pms"): @@ -279,4 +289,9 @@ if apps.is_installed("pms"): views.dashboard_feedback_table, name="dashboard-feedback-table", ), + path( + "dashboard-feedback-table-cbv/", + exit_process.DashboardFeedbackView.as_view(), + name="dashboard-feedback-table-cbv", + ), ]