diff --git a/leave/filters.py b/leave/filters.py index bab845300..d56901d22 100644 --- a/leave/filters.py +++ b/leave/filters.py @@ -335,7 +335,7 @@ class LeaveAllocationRequestFilter(FilterSet): leave_type = filters.CharFilter( field_name="leave_type_id__name", lookup_expr="icontains" ) - employee_id = filters.CharFilter( + employee = filters.CharFilter( field_name="employee_id__employee_first_name", lookup_expr="icontains" ) number_of_days = filters.NumberFilter( @@ -349,5 +349,7 @@ class LeaveAllocationRequestFilter(FilterSet): model = LeaveAllocationRequest fields = { 'created_by':["exact"], - "status":["exact"] + "status":["exact"], + "leave_type_id":["exact"], + "employee_id":["exact"] } diff --git a/leave/forms.py b/leave/forms.py index b437b3585..c732a3938 100644 --- a/leave/forms.py +++ b/leave/forms.py @@ -562,18 +562,19 @@ class UserLeaveRequestCreationForm(ModelForm): } 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 \ No newline at end of file + return table_html + class Meta: + model = LeaveAllocationRequest + fields = [ + 'leave_type_id', + 'employee_id', + 'requested_days', + 'description' + ] \ No newline at end of file diff --git a/leave/models.py b/leave/models.py index 0cdee257f..51e231f3a 100644 --- a/leave/models.py +++ b/leave/models.py @@ -1,4 +1,5 @@ import calendar +from collections.abc import Iterable from datetime import datetime, timedelta from django.db import models from django.utils import timezone @@ -529,3 +530,9 @@ class LeaveAllocationRequest(models.Model): created_at = models.DateTimeField(auto_now="True") reject_reason = models.TextField(blank=True) objects = models.Manager() + + def __str__(self): + return f"{self.employee_id}| {self.leave_type_id}| {self.id}" + + def save(self, *args, **kwargs): + super().save(*args,**kwargs) \ No newline at end of file diff --git a/leave/templates/leave/leave_allocation_request/leave_allocation_request_list.html b/leave/templates/leave/leave_allocation_request/leave_allocation_request_list.html index ee132eae5..27be4055f 100644 --- a/leave/templates/leave/leave_allocation_request/leave_allocation_request_list.html +++ b/leave/templates/leave/leave_allocation_request/leave_allocation_request_list.html @@ -15,19 +15,19 @@ {% comment %} {% if not request.GET.dashboard %} {% endcomment %} {% if leave_allocation_requests %}