Skip to content

Commit

Permalink
Fixed 'projectbegroting' edit form
Browse files Browse the repository at this point in the history
  • Loading branch information
reinout committed Jul 18, 2024
1 parent 8d80c17 commit 8fdd295
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
----------------
Expand Down
29 changes: 24 additions & 5 deletions trs/templates/trs/project-budget-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ <h1>{{ view.title }}</h1>
</div>
{% endfor %}


{% for error in view.project_form.errors.values %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}

<form action="." method="post">
{% csrf_token %}

Expand Down Expand Up @@ -58,6 +53,9 @@ <h1>{{ view.title }}</h1>
</td>
<td title="{{ form.amount.label }}">
{{ form.amount }}
{% for error in form.amount.errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
</td>
<td title="delete">
{{ form.DELETE }}
Expand Down Expand Up @@ -92,6 +90,9 @@ <h1>{{ view.title }}</h1>
{% for form in view.project_member_formset %}
<tr>
{{ form.person_id }}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
<td>
&nbsp;&nbsp;&nbsp;
{{ form.person.as_widget }}
Expand All @@ -114,6 +115,9 @@ <h1>{{ view.title }}</h1>

<td title="{{ form.hours.label }}">
{{ form.hours }}
{% for error in form.hours.errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
</td>
<td>
<span class="text-muted">
Expand All @@ -122,6 +126,9 @@ <h1>{{ view.title }}</h1>
</td>
<td title="{{ form.hourly_tariff.label }}">
{{ form.hourly_tariff }}
{% for error in form.hourly_tariff.errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
</td>
<td>
{{ form.person.standard_hourly_tariff }}
Expand Down Expand Up @@ -167,6 +174,9 @@ <h1>{{ view.title }}</h1>
</td>
<td>
{{ view.project_form.reservation }}
{% for error in view.project_form.reservation.errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
</td>
<td>
</td>
Expand Down Expand Up @@ -205,6 +215,9 @@ <h1>{{ view.title }}</h1>
</td>
<td title="{{ form.amount.label }}">
{{ form.amount }}
{% for error in form.amount.errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
</td>
<td title="delete">
{{ form.DELETE }}
Expand Down Expand Up @@ -254,6 +267,9 @@ <h1>{{ view.title }}</h1>
</td>
<td>
{{ view.project_form.software_development }}
{% for error in view.project_form.software_development.errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
</td>
<td>
</td>
Expand All @@ -266,6 +282,9 @@ <h1>{{ view.title }}</h1>
</td>
<td>
{{ view.project_form.profit }}
{% for error in view.project_form.profit.errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
</td>
<td>
</td>
Expand Down
9 changes: 8 additions & 1 deletion trs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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):
Expand Down

0 comments on commit 8fdd295

Please sign in to comment.