2023-06-06 12:27:41 +05:30
|
|
|
"""
|
|
|
|
|
methods.py
|
|
|
|
|
|
|
|
|
|
This page is used to write reusable methods.
|
|
|
|
|
|
|
|
|
|
"""
|
2023-05-10 15:06:57 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_stagemanager(request):
|
|
|
|
|
"""
|
2023-06-06 12:27:41 +05:30
|
|
|
This method is used to check stage manager, if the employee is also
|
|
|
|
|
recruitment manager it returns true
|
2023-05-10 15:06:57 +05:30
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
employee = request.user.employee_get
|
|
|
|
|
return employee.recruitment_set.exists() or employee.stage_set.exists()
|
2023-06-06 12:27:41 +05:30
|
|
|
except Exception:
|
2023-05-10 15:06:57 +05:30
|
|
|
return False
|
|
|
|
|
|
2023-06-06 12:27:41 +05:30
|
|
|
|
2023-05-10 15:06:57 +05:30
|
|
|
def is_recruitmentmanager(request):
|
|
|
|
|
"""
|
|
|
|
|
This method is used to check the employee is recruitment manager or not
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
employee = request.user.employee_get
|
|
|
|
|
return employee.recruitment_set.exists()
|
2023-06-06 12:27:41 +05:30
|
|
|
except Exception:
|
2023-05-10 15:06:57 +05:30
|
|
|
return False
|
|
|
|
|
|
2023-06-06 12:27:41 +05:30
|
|
|
|
|
|
|
|
def stage_manages(request, stage):
|
2023-05-10 15:06:57 +05:30
|
|
|
"""
|
|
|
|
|
This method is used to check the employee manager to this stage."""
|
|
|
|
|
try:
|
|
|
|
|
employee = request.user.employee_get
|
|
|
|
|
|
2023-06-06 12:27:41 +05:30
|
|
|
return (
|
|
|
|
|
stage.stage_manager.filter(id=employee.id).exists()
|
|
|
|
|
or stage.recruitment_id.recruitment_managers.filter(id=employee.id).exists()
|
|
|
|
|
)
|
2023-05-10 15:06:57 +05:30
|
|
|
except Exception:
|
|
|
|
|
return False
|
|
|
|
|
|
2023-06-06 12:27:41 +05:30
|
|
|
|
|
|
|
|
def recruitment_manages(request, recruitment):
|
2023-05-10 15:06:57 +05:30
|
|
|
"""
|
|
|
|
|
This method is used to check the employee is manager to the current recruitment
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
employee = request.user.employee_get
|
|
|
|
|
return recruitment.recruitment_managers.filter(id=employee.id).exists()
|
|
|
|
|
except Exception:
|
2023-06-06 12:27:41 +05:30
|
|
|
return False
|