diff --git a/CHANGES.rst b/CHANGES.rst index 887a5c2..1264fac 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,9 @@ Changelog of TRS - Fixed person creation. Name wasn't getting set. All name updates to User are handled now, fixing the problem. +- Fixed 'projectbegroting' form, which didn't display errors (and the form itself) + properly when there was a validation error. + 2.1 (2022-08-08) ---------------- diff --git a/trs/templates/trs/project-budget-edit.html b/trs/templates/trs/project-budget-edit.html index b223d8d..48fdc7e 100644 --- a/trs/templates/trs/project-budget-edit.html +++ b/trs/templates/trs/project-budget-edit.html @@ -15,11 +15,6 @@

{{ view.title }}

{% endfor %} - - {% for error in view.project_form.errors.values %} -
{{ error }}
- {% endfor %} -
{% csrf_token %} @@ -58,6 +53,9 @@

{{ view.title }}

{{ form.amount }} + {% for error in form.amount.errors %} +
{{ error }}
+ {% endfor %} {{ form.DELETE }} @@ -92,6 +90,9 @@

{{ view.title }}

{% for form in view.project_member_formset %} {{ form.person_id }} + {% for error in form.non_field_errors %} +
{{ error }}
+ {% endfor %}     {{ form.person.as_widget }} @@ -114,6 +115,9 @@

{{ view.title }}

{{ form.hours }} + {% for error in form.hours.errors %} +
{{ error }}
+ {% endfor %} @@ -122,6 +126,9 @@

{{ view.title }}

{{ form.hourly_tariff }} + {% for error in form.hourly_tariff.errors %} +
{{ error }}
+ {% endfor %} {{ form.person.standard_hourly_tariff }} @@ -167,6 +174,9 @@

{{ view.title }}

{{ view.project_form.reservation }} + {% for error in view.project_form.reservation.errors %} +
{{ error }}
+ {% endfor %} @@ -205,6 +215,9 @@

{{ view.title }}

{{ form.amount }} + {% for error in form.amount.errors %} +
{{ error }}
+ {% endfor %} {{ form.DELETE }} @@ -254,6 +267,9 @@

{{ view.title }}

{{ view.project_form.software_development }} + {% for error in view.project_form.software_development.errors %} +
{{ error }}
+ {% endfor %} @@ -266,6 +282,9 @@

{{ view.title }}

{{ view.project_form.profit }} + {% for error in view.project_form.profit.errors %} +
{{ error }}
+ {% endfor %} diff --git a/trs/views.py b/trs/views.py index 18d3def..f343742 100644 --- a/trs/views.py +++ b/trs/views.py @@ -2178,7 +2178,7 @@ def post(self, *args, **kwargs): and self.budget_item_formset.is_valid() and self.project_member_formset.is_valid() ): - + logger.debug("All forms are valid") self.project_form.save() self.estimate_formset.save() self.budget_item_formset.save() @@ -2197,7 +2197,14 @@ def post(self, *args, **kwargs): return HttpResponseRedirect(self.success_url) else: + messages.error(self.request, "Corrigeer de fouten hieronder") context = self.get_context_data(**kwargs) + context["project_form"] = self.project_form + context["new_member_form"] = self.new_member_form + context["estimate_formset"] = self.estimate_formset + context["budget_item_formset"] = self.budget_item_formset + context["project_member_formset"] = self.project_member_formset + self.adjust_project_member_formset() return self.render_to_response(context) def add_team_member(self, id):