diff --git a/attendance/models.py b/attendance/models.py index 5f96c092e..e46382a0e 100644 --- a/attendance/models.py +++ b/attendance/models.py @@ -674,6 +674,15 @@ class AttendanceOverTime(models.Model): unique_together = [("employee_id"), ("month"), ("year")] ordering = ["-year", "-month_sequence"] + def clean(self): + try: + year = int(self.year) + if not (1900 <= year <= 2100): + raise ValidationError({"year": _("Year must be an integer value between 1900 and 2100")}) + except (ValueError, TypeError): + raise ValidationError({"year": _("Year must be an integer value between 1900 and 2100")}) + + def month_days(self): """ this method is used to create new AttendanceOvertime's instance if there diff --git a/attendance/templates/attendance/attendance_account/form.html b/attendance/templates/attendance/attendance_account/form.html index 0a712aa0a..b94c5d940 100644 --- a/attendance/templates/attendance/attendance_account/form.html +++ b/attendance/templates/attendance/attendance_account/form.html @@ -1,8 +1,28 @@ {% load i18n %} -