2024-05-09 14:28:24 +05:30
|
|
|
"""
|
|
|
|
|
offboarding/sidebar.py
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from django.urls import reverse
|
2024-12-31 19:00:43 +05:30
|
|
|
from django.utils.translation import gettext_lazy as _
|
2024-05-09 15:01:06 +05:30
|
|
|
|
2024-05-09 14:28:24 +05:30
|
|
|
from base.context_processors import resignation_request_enabled
|
|
|
|
|
from offboarding.templatetags.offboarding_filter import (
|
|
|
|
|
any_manager,
|
|
|
|
|
is_offboarding_employee,
|
|
|
|
|
)
|
|
|
|
|
|
2024-12-31 19:00:43 +05:30
|
|
|
MENU = _("Offboarding")
|
2024-05-09 14:28:24 +05:30
|
|
|
IMG_SRC = "images/ui/exit-outline.svg"
|
|
|
|
|
ACCESSIBILITY = "offboarding.sidebar.offboarding_accessibility"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SUBMENUS = [
|
2025-04-08 12:09:07 +05:30
|
|
|
{
|
|
|
|
|
"menu": _("Dashboard"),
|
|
|
|
|
"redirect": reverse("offboarding-dashboard"),
|
|
|
|
|
"accessibility": "offboarding.sidebar.dashboard_accessibility",
|
|
|
|
|
},
|
2024-05-09 14:28:24 +05:30
|
|
|
{
|
2024-12-31 19:00:43 +05:30
|
|
|
"menu": _("Exit Process"),
|
2024-05-09 14:28:24 +05:30
|
|
|
"redirect": reverse("offboarding-pipeline"),
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-12-31 19:00:43 +05:30
|
|
|
"menu": _("Resignation Letters"),
|
2024-05-09 14:28:24 +05:30
|
|
|
"redirect": reverse("resignation-request-view"),
|
2024-05-21 13:04:25 +05:30
|
|
|
"accessibility": "offboarding.sidebar.resignation_letter_accessibility",
|
2024-05-09 14:28:24 +05:30
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def offboarding_accessibility(request, menu, user_perms, *args, **kwargs):
|
2024-05-10 11:13:56 +05:30
|
|
|
accessible = False
|
|
|
|
|
try:
|
|
|
|
|
accessible = (
|
2025-04-08 12:09:07 +05:30
|
|
|
request.user.has_module_perms("offboarding")
|
2024-05-10 11:13:56 +05:30
|
|
|
or any_manager(request.user.employee_get)
|
|
|
|
|
or is_offboarding_employee(request.user.employee_get)
|
|
|
|
|
)
|
|
|
|
|
finally:
|
|
|
|
|
return accessible
|
2024-05-09 14:28:24 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def resignation_letter_accessibility(request, menu, user_perms, *args, **kwargs):
|
|
|
|
|
return resignation_request_enabled(request)[
|
|
|
|
|
"enabled_resignation_request"
|
|
|
|
|
] and request.user.has_perm("offboarding.view_resignationletter")
|
2025-04-08 12:09:07 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def dashboard_accessibility(request, *args):
|
|
|
|
|
"""
|
|
|
|
|
Check if the user has permission to view the dashboard.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
return request.user.has_module_perms("offboarding") or any_manager(
|
|
|
|
|
request.user.employee_get
|
|
|
|
|
)
|