2023-12-01 15:36:51 +05:30
|
|
|
"""
|
|
|
|
|
context_processor.py
|
|
|
|
|
|
|
|
|
|
This module is used to register context processor`
|
|
|
|
|
"""
|
2024-03-10 19:37:46 +05:30
|
|
|
|
2023-12-01 15:36:51 +05:30
|
|
|
from django.http import HttpResponse
|
2024-05-07 12:23:36 +05:30
|
|
|
from django.urls import path
|
|
|
|
|
|
2024-01-29 15:08:36 +05:30
|
|
|
from attendance.models import AttendanceGeneralSetting
|
2023-12-01 15:36:51 +05:30
|
|
|
from base.models import Company
|
|
|
|
|
from base.urls import urlpatterns
|
2024-02-01 13:09:43 +05:30
|
|
|
from employee.models import EmployeeGeneralSetting
|
2024-01-25 16:36:49 +05:30
|
|
|
from offboarding.models import OffboardingGeneralSetting
|
2024-01-30 19:10:54 +05:30
|
|
|
from payroll.models.models import PayrollGeneralSetting
|
2024-01-31 11:42:29 +05:30
|
|
|
from recruitment.models import RecruitmentGeneralSetting
|
2023-12-01 15:36:51 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
class AllCompany:
|
|
|
|
|
"""
|
|
|
|
|
Dummy class
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
class Urls:
|
|
|
|
|
url = "https://ui-avatars.com/api/?name=All+Company&background=random"
|
|
|
|
|
|
|
|
|
|
company = "All Company"
|
|
|
|
|
icon = Urls()
|
|
|
|
|
text = "All companies"
|
|
|
|
|
id = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_companies(request):
|
|
|
|
|
"""
|
|
|
|
|
This method will return the history additional field form
|
|
|
|
|
"""
|
|
|
|
|
companies = list(
|
|
|
|
|
[company.id, company.company, company.icon.url, False]
|
|
|
|
|
for company in Company.objects.all()
|
|
|
|
|
)
|
|
|
|
|
companies = [
|
|
|
|
|
[
|
|
|
|
|
"all",
|
|
|
|
|
"All Company",
|
|
|
|
|
"https://ui-avatars.com/api/?name=All+Company&background=random",
|
|
|
|
|
False,
|
|
|
|
|
],
|
|
|
|
|
] + companies
|
|
|
|
|
selected_company = request.session.get("selected_company")
|
|
|
|
|
company_selected = False
|
|
|
|
|
if selected_company and selected_company == "all":
|
|
|
|
|
companies[0][3] = True
|
|
|
|
|
company_selected = True
|
|
|
|
|
else:
|
|
|
|
|
for company in companies:
|
|
|
|
|
if str(company[0]) == selected_company:
|
|
|
|
|
company[3] = True
|
|
|
|
|
company_selected = True
|
|
|
|
|
return {"all_companies": companies, "company_selected": company_selected}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_selected_company(request):
|
|
|
|
|
"""
|
|
|
|
|
This method is used to update the selected company on the session
|
|
|
|
|
"""
|
|
|
|
|
company_id = request.GET.get("company_id")
|
|
|
|
|
request.session["selected_company"] = company_id
|
|
|
|
|
company = (
|
|
|
|
|
AllCompany()
|
|
|
|
|
if company_id == "all"
|
|
|
|
|
else (
|
|
|
|
|
Company.objects.filter(id=company_id).first()
|
|
|
|
|
if Company.objects.filter(id=company_id).first()
|
|
|
|
|
else AllCompany()
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
text = "Other Company"
|
|
|
|
|
if company_id == request.user.employee_get.employee_work_info.company_id:
|
|
|
|
|
text = "My Company"
|
|
|
|
|
if company_id == "all":
|
|
|
|
|
text = "All companies"
|
|
|
|
|
company = {
|
|
|
|
|
"company": company.company,
|
|
|
|
|
"icon": company.icon.url,
|
|
|
|
|
"text": text,
|
|
|
|
|
"id": company.id,
|
|
|
|
|
}
|
|
|
|
|
request.session["selected_company_instance"] = company
|
|
|
|
|
return HttpResponse("<script>window.location.reload();</script>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
urlpatterns.append(
|
|
|
|
|
path(
|
|
|
|
|
"update-selected-company",
|
|
|
|
|
update_selected_company,
|
|
|
|
|
name="update-selected-company",
|
|
|
|
|
)
|
|
|
|
|
)
|
2024-01-25 16:36:49 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def resignation_request_enabled(request):
|
|
|
|
|
"""
|
|
|
|
|
Check weather resignation_request enabled of not in offboarding
|
|
|
|
|
"""
|
|
|
|
|
first = OffboardingGeneralSetting.objects.first()
|
|
|
|
|
enabled_resignation_request = True
|
|
|
|
|
if first:
|
|
|
|
|
enabled_resignation_request = first.resignation_request
|
|
|
|
|
return {"enabled_resignation_request": enabled_resignation_request}
|
2024-01-29 15:08:36 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def timerunner_enabled(request):
|
|
|
|
|
"""
|
|
|
|
|
Check weather resignation_request enabled of not in offboarding
|
|
|
|
|
"""
|
|
|
|
|
first = AttendanceGeneralSetting.objects.first()
|
|
|
|
|
enabled_timerunner = True
|
|
|
|
|
if first:
|
|
|
|
|
enabled_timerunner = first.time_runner
|
|
|
|
|
return {"enabled_timerunner": enabled_timerunner}
|
2024-01-30 19:10:54 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def intial_notice_period(request):
|
|
|
|
|
"""
|
|
|
|
|
Check weather resignation_request enabled of not in offboarding
|
|
|
|
|
"""
|
|
|
|
|
first = PayrollGeneralSetting.objects.first()
|
2024-03-21 14:22:49 +05:30
|
|
|
initial = 30
|
2024-01-30 19:10:54 +05:30
|
|
|
if first:
|
|
|
|
|
initial = first.notice_period
|
|
|
|
|
return {"get_initial_notice_period": initial}
|
2024-01-31 11:42:29 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_candidate_self_tracking(request):
|
|
|
|
|
"""
|
|
|
|
|
This method is used to get the candidate self tracking is enabled or not
|
|
|
|
|
"""
|
|
|
|
|
first = RecruitmentGeneralSetting.objects.first()
|
|
|
|
|
candidate_self_tracking = False
|
|
|
|
|
if first:
|
|
|
|
|
candidate_self_tracking = first.candidate_self_tracking
|
|
|
|
|
return {"check_candidate_self_tracking": candidate_self_tracking}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_candidate_self_tracking_rating(request):
|
|
|
|
|
"""
|
|
|
|
|
This method is used to check enabled/disabled of rating option
|
|
|
|
|
"""
|
|
|
|
|
first = RecruitmentGeneralSetting.objects.first()
|
|
|
|
|
rating_option = False
|
|
|
|
|
if first:
|
|
|
|
|
rating_option = first.show_overall_rating
|
|
|
|
|
return {"check_candidate_self_tracking_rating": rating_option}
|
2024-02-01 13:09:43 +05:30
|
|
|
|
|
|
|
|
|
2024-04-15 16:23:21 +05:30
|
|
|
def get_initial_prefix(request):
|
2024-02-01 13:09:43 +05:30
|
|
|
"""
|
2024-04-15 16:23:21 +05:30
|
|
|
This method is used to get the initial prefix
|
2024-02-01 13:09:43 +05:30
|
|
|
"""
|
|
|
|
|
settings = EmployeeGeneralSetting.objects.first()
|
|
|
|
|
instance_id = None
|
|
|
|
|
prefix = "PEP"
|
|
|
|
|
if settings:
|
|
|
|
|
instance_id = settings.id
|
|
|
|
|
prefix = settings.badge_id_prefix
|
2024-04-15 16:23:21 +05:30
|
|
|
return {"get_initial_prefix": prefix, "prefix_instance_id": instance_id}
|
2024-04-17 21:56:01 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def biometric_app_exists(request):
|
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
|
|
biometric_app_exists = "biometric" in settings.INSTALLED_APPS
|
|
|
|
|
return {"biometric_app_exists": biometric_app_exists}
|