[ADD] ATTENDANCE: Check in check out enable disable feature added

This commit is contained in:
Horilla
2024-12-24 00:02:23 +05:30
parent 4ab8e3622e
commit c01d38d34c
9 changed files with 422 additions and 237 deletions

View File

@@ -41,4 +41,4 @@
{% endif %}
</div>
</div>
</div>
</div>

View File

@@ -16,7 +16,7 @@ from django.template import TemplateSyntaxError
from django.template.defaultfilters import register
from django.utils.translation import gettext as _
from base.models import EmployeeShiftSchedule
from base.models import Company, EmployeeShiftSchedule
from employee.methods.duration_methods import strtime_seconds
from horilla.horilla_middlewares import _thread_locals
from horilla.methods import get_horilla_model_class
@@ -307,3 +307,32 @@ def currency_symbol_position(amount):
currency_symbol = f"{currency} {amount}"
return currency_symbol
@register.filter(name="is_check_in_enabled")
def is_check_in_enabled(request):
"""
This method checks whether the check-in/check-out feature is enabled.
"""
from attendance.models import AttendanceGeneralSetting
# from base.models import Company # Assuming Company is the correct model for `selected_company`
selected_company = request.session.get("selected_company")
if not selected_company:
return False # Safeguard if session key is missing
# Fetch the settings based on the selected company
if selected_company == "all":
attendance_settings, created = AttendanceGeneralSetting.objects.get_or_create(
company_id=None
)
else:
company = Company.objects.filter(id=selected_company).first()
if not company:
return False # Return False if the company doesn't exist
attendance_settings, created = AttendanceGeneralSetting.objects.get_or_create(
company_id=company
)
# Check if check-in is enabled
return bool(attendance_settings and attendance_settings.enable_check_in)