Skip to content

Commit

Permalink
alerts: replace old alerts in form templates
Browse files Browse the repository at this point in the history
  • Loading branch information
hom3mad3 authored and vellip committed Jan 28, 2025
1 parent 5a5fe85 commit 193cce3
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ <h2>{% blocktranslate %}Contact Information{% endblocktranslate %}</h2>
{% blocktranslate with privacy_policy="/datenschutz" %}I hereby expressly consent to the storage of the contact information I have entered. The contact information may be used by the responsible administration exclusively for contacting me in the present project. I can revoke this consent at any time. I have read and accept the <a href="{{privacy_policy}}" target="_blank">privacy policy</a>.{% endblocktranslate %}
</label>
{% if form.contact_storage_consent.errors %}
{% if form.contact_storage_consent.errors|length > 1 %}
<ul class="errorlist" aria-live="assertive" aria-atomic="true">
{% for error in form.contact_storage_consent.errors %}
<li>{{ error|escape }}</li>
{% endfor %}
{% for error in form.contact_storage_consent.errors %}
<li>{{ error|escape }}</li>
{% endfor %}
</ul>
{% else %}
{% include 'meinberlin_contrib/components/alert.html' with alert_message=form.contact_storage_consent.errors.0|escape alert_type='danger' %}
{% endif %}
{% endif %}
</div>

{% include 'meinberlin_contrib/includes/form_submit_actions.html' with button_text='Send' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
<h1>{% translate 'Edit proposal' %}</h1>

{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='Error during validation. Please check your entries.' alert_type='danger' %}
{% endif %}

{% include "meinberlin_budgeting/includes/proposal_form.html" with proposal=proposal cancel=object.get_absolute_url %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{% load i18n item_tags contrib_tags moderatorremark_tags %}

<form enctype="multipart/form-data" action="{{ request.path }}" method="post">
<form class="form--base panel--heavy" enctype="multipart/form-data" action="{{ request.path }}" method="post">
{% csrf_token %}
{% for form in forms.values %}
{{ form.media }}
{% endfor %}

{% include 'meinberlin_contrib/includes/form_field_select.html' with field=forms.moderateable.moderator_status %}
{% include 'meinberlin_contrib/includes/form_field.html' with field=forms.feedback_text.feedback_text %}
{% include 'meinberlin_contrib/includes/form_checkbox_field.html' with field=forms.moderateable.is_archived %}
{% if forms.moderateable.is_archived %}
{% include 'meinberlin_contrib/includes/form_checkbox_field.html' with field=forms.moderateable.is_archived %}
{% endif %}
{% if forms.moderateable.show_tasks %}
{% include 'meinberlin_contrib/includes/form_field.html' with field=forms.moderateable.completed_tasks add_class='u-top-divider' %}
{% include 'meinberlin_contrib/includes/form_field.html' with field=forms.remark.remark %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
{% endif %}
</label>
{% if field.errors %}
<ul class="errorlist" aria-live="assertive" aria-atomic="true">
{% for error in field.errors %}
<li>{{ error|escape }}</li>
{% endfor %}
</ul>
{% endif %}
{% if field.errors|length > 1 %}
<ul class="errorlist" aria-live="assertive" aria-atomic="true">
{% for error in field.errors %}
<li>{{ error|escape }}</li>
{% endfor %}
</ul>
{% else %}
{% include 'meinberlin_contrib/components/alert.html' with alert_message=field.errors.0|escape alert_type='danger' %}
{% endif %}
{% endif %}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
<h1 class="u-first-heading">{% translate 'Add a new place' %}</h1>

{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='An error occurred while evaluating your data. Please check the data you entered again.' alert_type='danger' %}
{% endif %}

{% url 'a4dashboard:maptopic-list' module_slug=module.slug as cancel %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
<h1 class="u-first-heading">{% translate 'Edit place' %}</h1>

{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='An error occurred while evaluating your data. Please check the data you entered again.' alert_type='danger' %}
{% endif %}

{% url 'a4dashboard:maptopic-list' module_slug=module.slug as cancel %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<h1 class="u-first-heading">{% translate 'Add a new offline event'%}</h1>

{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='An error occurred while evaluating your data. Please check the data you entered again.' alert_type='danger' %}
{% endif %}

{% url 'a4dashboard:offlineevent-list' project_slug=project.slug as cancel %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
<h1 class="u-first-heading">{% translate 'Edit offline event' %}</h1>

{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='An error occurred while evaluating your data. Please check the data you entered again.' alert_type='danger' %}
{% endif %}

{% url 'a4dashboard:offlineevent-list' project_slug=project.slug as cancel %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
{{ form.media }}

{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='An error occurred while evaluating your data. Please check the data you entered again.' alert_type='danger' %}
{% endif %}

<h2 class="form__subheading"> {% translate 'Description of the plan' %}</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
<form method="POST">
{% csrf_token %}
{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='An error occurred while evaluating your data. Please check the data you entered again.' alert_type='danger' %}
{% endif %}

<div class="form-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ <h1 class="u-first-heading">{% translate 'Generate voting codes' %}</h1>
<form method="POST">
{% csrf_token %}
{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='An error occurred while evaluating your data. Please check the data you entered again.' alert_type='danger' %}
{% endif %}

{% if form.non_field_errors %}
Expand Down
4 changes: 1 addition & 3 deletions meinberlin/templates/a4dashboard/base_form_module.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<h1 class="u-first-heading">{{ view.title }}</h1>

{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='An error occurred while evaluating your data. Please check the data you entered again.' alert_type='danger' %}
{% endif %}

{% if form.non_field_errors %}
Expand Down
4 changes: 1 addition & 3 deletions meinberlin/templates/a4dashboard/base_form_project.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<h1 class="u-first-heading">{{ view.title }}</h1>

{% if form.errors %}
<div class="alert alert--danger" aria-live="assertive" aria-atomic="true" id="alert">
{% translate 'An error occurred while evaluating your data. Please check the data you entered again.' %}
</div>
{% include 'meinberlin_contrib/components/alert.html' with alert_message='An error occurred while evaluating your data. Please check the data you entered again.' alert_type='danger' %}
{% endif %}

{% if form.non_field_errors %}
Expand Down
12 changes: 12 additions & 0 deletions meinberlin/templates/a4forms/includes/form_checkbox_field.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@
{% endfor %}
</ul>
{% endif %}

{% if field.errors %}
{% if field.errors|length > 1 %}
<ul class="errorlist" aria-live="assertive" aria-atomic="true">
{% for error in field.errors %}
<li>{{ error|escape }}</li>
{% endfor %}
</ul>
{% else %}
{% include 'meinberlin_contrib/components/alert.html' with alert_message=field.errors.0|escape alert_type='danger' %}
{% endif %}
{% endif %}
</div>

0 comments on commit 193cce3

Please sign in to comment.