[FIX] LEAVE: Infinite leave days issue in MySQL databases (#318)

This commit is contained in:
Horilla
2024-09-05 17:06:24 +05:30
parent 0e9c8a5b24
commit a35dc09b3a

View File

@@ -46,6 +46,7 @@ from leave.models import (
)
CHOICES = [("yes", _("Yes")), ("no", _("No"))]
LEAVE_MAX_LIMIT = 1e5
class ModelForm(forms.ModelForm):
@@ -193,7 +194,12 @@ class LeaveTypeForm(ConditionForm):
del self.errors["exceed_days"]
cleaned_data["total_days"] = round(cleaned_data["total_days"] * 2) / 2
if not cleaned_data["limit_leave"]:
cleaned_data["total_days"] = math.inf
cleaned_data["total_days"] = LEAVE_MAX_LIMIT
cleaned_data["reset"] = True
cleaned_data["reset_based"] = "yearly"
cleaned_data["reset_month"] = "1"
cleaned_data["reset_day"] = "1"
return cleaned_data
def save(self, *args, **kwargs):
@@ -245,7 +251,12 @@ class UpdateLeaveTypeForm(ConditionForm):
del self.errors["exceed_days"]
cleaned_data["count"] = round(cleaned_data["count"] * 2) / 2
if not cleaned_data["limit_leave"]:
cleaned_data["count"] = math.inf
print(LEAVE_MAX_LIMIT)
cleaned_data["total_days"] = LEAVE_MAX_LIMIT
cleaned_data["reset"] = True
cleaned_data["reset_based"] = "yearly"
cleaned_data["reset_month"] = "1"
cleaned_data["reset_day"] = "1"
return cleaned_data