diff --git a/base/forms.py b/base/forms.py index 03ebd9fab..8e3fb5e65 100644 --- a/base/forms.py +++ b/base/forms.py @@ -2624,6 +2624,15 @@ class CompanyLeaveForm(ModelForm): fields = "__all__" exclude = ["is_active"] + def __init__(self, *args, **kwargs): + """ + Custom initialization to configure the 'based_on' field. + """ + super().__init__(*args, **kwargs) + self.fields["based_on_week"].widget.option_template_name = ( + "horilla_widgets/select_option.html" + ) + class PenaltyAccountForm(ModelForm): """ diff --git a/base/templates/company_leave/company_leave_creation_form.html b/base/templates/company_leave/company_leave_creation_form.html index 8e811edc8..6e5aaf81a 100644 --- a/base/templates/company_leave/company_leave_creation_form.html +++ b/base/templates/company_leave/company_leave_creation_form.html @@ -1,63 +1,43 @@ -{% load i18n %} {% if messages %} -
- {% for message in messages %} -
-
- {{ message }} +{% load i18n %} +{% if messages %} + + +{% endif %} +{% if form.errors %} +
+
+ {% for error in form.non_field_errors %} +
{{ error }}
+ {% endfor %} +
-
- {% endfor %} -
- -{% endif %} {% if form.errors %} -
-
- {% for error in form.non_field_errors %} -
{{ error }}
- {% endfor %} -
-
{% endif %}
- {% trans "Create Company Leaves" %} - + {% trans "Create Company Leaves" %} +
-
- - {{form.based_on_week}} {{form.based_on_week.errors}} - - {{form.based_on_week_day}} {{form.based_on_week_day.errors}} - -
+
+ + {{form.based_on_week}} {{form.based_on_week.errors}} + + {{form.based_on_week_day}} {{form.based_on_week_day.errors}} + +
diff --git a/base/templates/company_leave/company_leave_update_form.html b/base/templates/company_leave/company_leave_update_form.html index ac65d54bc..7d426b241 100644 --- a/base/templates/company_leave/company_leave_update_form.html +++ b/base/templates/company_leave/company_leave_update_form.html @@ -1,65 +1,41 @@ -{% load i18n %} {% if messages %} -
- {% for message in messages %} -
-
- {{ message }} -
-
- {% endfor %} -
- +{% load i18n %} +{% if messages %} + + {% endif %} {% if form.errors %} - -
-
- {% for error in form.non_field_errors %} -
{{ error }}
- {% endfor %} -
-
+
+
+ {% for error in form.non_field_errors %} +
{{ error }}
+ {% endfor %} +
+
{% endif %}
- {% trans "Update Company Leaves" %} - + {% trans "Update Company Leaves" %} +
-
- - {{form.based_on_week}} - - {{form.based_on_week_day}} - -
+
+ + {{form.based_on_week}} + + {{form.based_on_week_day}} + +