[ADD] LEAVE: Leave allocation request

This commit is contained in:
Horilla
2023-11-02 12:25:48 +05:30
parent 617654a17c
commit 91ecbbf777
12 changed files with 834 additions and 97 deletions

View File

@@ -6,7 +6,7 @@ from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _
from django.template.loader import render_to_string
from employee.models import Employee
from .models import LeaveType, LeaveRequest, AvailableLeave, Holiday, CompanyLeave
from .models import LeaveType, LeaveRequest, AvailableLeave, Holiday, CompanyLeave, LeaveAllocationRequest
from .methods import (
calculate_requested_days,
leave_requested_dates,
@@ -560,4 +560,20 @@ class UserLeaveRequestCreationForm(ModelForm):
widgets = {
'employee_id': forms.HiddenInput()
}
class LeaveAllocationRequestForm(ModelForm):
class Meta:
model = LeaveAllocationRequest
fields = [
'leave_type_id',
'employee_id',
'requested_days',
'description',
]
def as_p(self, *args, **kwargs):
"""
Render the form fields as HTML table rows with Bootstrap styling.
"""
context = {"form": self}
table_html = render_to_string("attendance_form.html", context)
return table_html