[UPDT] OFFBOARDING: Added kanban view for exit process

This commit is contained in:
Horilla
2025-08-09 15:38:27 +05:30
parent 00d073cda1
commit 7c6b30512b
5 changed files with 148 additions and 12 deletions

View File

@@ -15,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_views.cbv_methods import login_required, permission_required
from horilla_views.generic.cbv.kanban import KanbanView
from horilla_views.generic.cbv.pipeline import Pipeline
from horilla_views.generic.cbv.views import (
HorillaDetailedView,
@@ -267,10 +268,11 @@ class OffboardingPipelineNav(HorillaNavView):
Offboarding Pipeline Navigation View
"""
nav_title = "Pipeline"
nav_title = "Exit Process"
search_swap_target = "#pipelineContainer"
search_url = reverse_lazy("get-offboarding-tab")
filter_body_template = "cbv/exit_process/pipeline_filter.html"
apply_first_filter = False
def __init__(self, **kwargs):
super().__init__(**kwargs)
@@ -283,6 +285,25 @@ class OffboardingPipelineNav(HorillaNavView):
data-target="#objectDetailsModal"
"""
self.view_types = [
{
"type": "list",
"icon": "list-outline",
"url": f'{reverse_lazy("get-offboarding-tab")}',
"attrs": f"""
title ='List'
""",
},
{
"type": "card",
"icon": "grid-outline",
"url": f'{reverse_lazy("get-offboarding-tab")}?view=card',
"attrs": f"""
title ='Card'
""",
},
]
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
@@ -299,18 +320,25 @@ class PipeLineTabView(HorillaTabView):
Pipeline List View
"""
filter_class = PipelineFilter
def __init__(self, **kwargs):
super().__init__(**kwargs)
offboardings = PipelineFilter(self.request.GET).qs.filter(is_active=True)
offboardings = self.filter_class(self.request.GET).qs.filter(is_active=True)
view_type = self.request.GET.get("view", "list")
self.tabs = []
for offboarding in offboardings:
tab = {}
tab["actions"] = []
tab["title"] = offboarding.title
tab["url"] = reverse(
"get-offboarding-stage", kwargs={"offboarding_id": offboarding.pk}
)
url = reverse("get-offboarding-kanban-stage", kwargs={"pk": offboarding.pk})
if view_type == "list":
url = reverse(
"get-offboarding-stage", kwargs={"offboarding_id": offboarding.pk}
)
tab["url"] = url
tab["badge_label"] = _("Stages")
if self.request.user.has_perm(
"offboarding.add_offboardingstage"
@@ -433,6 +461,41 @@ class OffboardingPipelineStage(Pipeline):
return self.queryset
class OffboardingKanbanView(KanbanView):
"""
Offboarding Kanban View
"""
model = OffboardingEmployee
filter_class = PipelineEmployeeFilter
group_key = "stage_id"
records_per_page = 10
show_kanban_confirmation = False
kanban_attrs = """
hx-get='{get_individual_url}'
hx-target='#genericModalBody'
data-toggle = 'oh-modal-toggle'
data-target="#genericModal"
data-group-order='{ordered_group_json}'
"""
details = {
"image_src": "{employee_id__get_avatar}",
"title": "{employee_id__get_full_name}",
"Notice period start": "{notice_period_starts}",
"Notice period end": "{notice_period_ends}",
}
def get_related_groups(self, *args, **kwargs):
related_groups = super().get_related_groups(*args, **kwargs)
off_id = self.kwargs.get("pk")
if off_id:
related_groups = related_groups.filter(offboarding_id=off_id)
return related_groups
@method_decorator(login_required, name="dispatch")
class OffboardingEmployeeList(HorillaListView):
"""

View File

@@ -153,17 +153,18 @@ class ResinationLettersNav(HorillaNavView):
super().__init__(**kwargs)
self.search_url = reverse("list-resignation-request")
self.create_attrs = f"""
hx-get="{reverse_lazy("resignation-requests-create")}"
hx-target="#genericModalBody"
data-target="#genericModal"
data-toggle="oh-modal-toggle"
"""
hx-get="{reverse_lazy("resignation-requests-create")}"
hx-target="#genericModalBody"
data-target="#genericModal"
data-toggle="oh-modal-toggle"
"""
nav_title = _("Resignations")
filter_instance = LetterFilter()
filter_form_context_name = "form"
filter_body_template = "cbv/resignation/filter.html"
search_swap_target = "#listContainer"
apply_first_filter = False
group_by_fields = [
("employee_id", _("Employee")),

View File

@@ -1,3 +1,4 @@
import json
from ast import literal_eval
from collections.abc import Iterable
from datetime import date, timedelta
@@ -271,6 +272,23 @@ class OffboardingEmployee(HorillaModel):
return value
def ordered_group_json(self):
"""
This method is used to get ordered group json
"""
Offboarding = self.stage_id.offboarding_id
offboarding_stages = Offboarding.offboardingstage_set.all().order_by("sequence")
ordered_group_json = json.dumps(
[
{
"id": stage.id,
"stage": stage.title,
}
for stage in offboarding_stages
]
)
return ordered_group_json
class ResignationLetter(HorillaModel):
"""

View File

@@ -1,6 +1,55 @@
{% extends "index.html" %}
{% block content %}
{% load static i18n %}
{% include "generic/horilla_section.html" %}
{% for path in style_static_paths %}
<link rel="stylesheet" href="{{path}}"/>
{% endfor %}
{% for path in script_static_paths %}
<script src="{% static path %}"></script>
{% endfor %}
{% include "generic/components.html" %}
<div
class="oh-checkpoint-badge mb-2"
id="selectedInstances"
data-ids="[]"
data-clicked=""
style="display: none"
>
</div>
{% if nav_url %}
<div
hx-get="{{nav_url}}?{{request.GET.urlencode}}"
hx-trigger="load"
>
<div
class="mt-5 oh-wrapper animated-background"
style="height:80px;"
>
</div>
</div>
{% endif %}
{% if view_url %}
<div
class="oh-wrapper"
id="{{view_container_id}}"
>
<div
class="mt-4 animated-background"
style="height:600px;"
>
</div>
</div>
{% endif %}
{% endblock content %}
<div
class="oh-modal"

View File

@@ -47,6 +47,11 @@ urlpatterns = [
exit_process.OffboardingPipelineStage.as_view(),
name="get-offboarding-stage",
),
path(
"get-offboarding-kanban-stage/<int:pk>/",
exit_process.OffboardingKanbanView.as_view(),
name="get-offboarding-kanban-stage",
),
path(
"get-offboarding-employees-cbv",
exit_process.OffboardingEmployeeList.as_view(),