Skip to content

Commit

Permalink
Merge pull request #5235 from nyaruka/alerts_vs_errors
Browse files Browse the repository at this point in the history
Don't use error level alerts for form errors
  • Loading branch information
rowanseymour authored May 15, 2024
2 parents 1eabf26 + 734469c commit 5a0384b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 38 deletions.
4 changes: 2 additions & 2 deletions templates/contacts/contact_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
</form>
</div>
{% if search_error %}
<temba-alert level="error" class="mt-4">
<div class="alert alert-error mt-4">
{{ search_error }}
</temba-alert>
</div>
{% endif %}
{% if org_perms.contacts.contact_delete %}
<temba-dialog header="{{ _("Delete Selected Contacts") |escapejs }}"
Expand Down
6 changes: 1 addition & 5 deletions templates/contacts/contactimport_preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
</div>
<form method="post" enctype="multipart/form-data" class="smartmin-form horizontal-form">
{% csrf_token %}
{% if form.non_field_errors %}
<temba-alert level="error" class="form-errors">
{{ form.non_field_errors }}
</temba-alert>
{% endif %}
{% if form.non_field_errors %}<div class="alert alert-error form-errors">{{ form.non_field_errors }}</div>{% endif %}
<div class="card w-full">
{% block fields %}
<fieldset>
Expand Down
6 changes: 1 addition & 5 deletions templates/orgs/login/confirm_access.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
<temba-textinput name="password" placeholder="{{ _("Password") |escape }}" password="true">
</temba-textinput>
</div>
{% if form.password.errors %}
<temba-alert level="error" class="mt-4">
{{ form.password.errors }}
</temba-alert>
{% endif %}
{% if form.password.errors %}<div class="alert alert-error mt-4">{{ form.password.errors }}</div>{% endif %}
<div class="mt-6">
<input type="submit" value="{{ _("Confirm") |escape }}" class="button-primary">
</div>
Expand Down
20 changes: 4 additions & 16 deletions templates/orgs/login/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@
{% blocktrans trimmed %}
Please sign in with your email address and password.
{% endblocktrans %}
<form method="POST" id="login-form">
<form method="post" id="login-form">
{% csrf_token %}
{% for field, errors in form.errors.items %}
{% if field == '__all__' %}
<temba-alert level="error" class="my-4">
{{ errors }}
</temba-alert>
{% endif %}
{% if field == '__all__' %}<div class="alert alert-error my-4">{{ errors }}</div>{% endif %}
{% endfor %}
<div class="mt-4">
<input type="text"
Expand All @@ -26,19 +22,11 @@
value="{% if form.username.value %}{{ form.username.value|escape }}{% endif %}"
class="input">
</div>
{% if form.username.errors %}
<temba-alert level="error" class="mt-4">
{{ form.username.errors }}
</temba-alert>
{% endif %}
{% if form.username.errors %}<div class="alert alert-error mt-4">{{ form.username.errors }}</div>{% endif %}
<div class="mt-4">
<input type="password" name="password" placeholder="{{ _("Password") |escapejs }}" class="input">
</div>
{% if form.password.errors %}
<temba-alert level="error" class="mt-4">
{{ form.password.errors }}
</temba-alert>
{% endif %}
{% if form.password.errors %}<div class="alert alert-error mt-4">{{ form.password.errors }}</div>{% endif %}
<div class="mt-2 text-right">
<a href="/user/forget/">Forgot your password?</a>
</div>
Expand Down
6 changes: 1 addition & 5 deletions templates/orgs/login/two_factor_backup.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
<temba-textinput name="token" maxlength="8" placeholder="{{ _("8-character token") |escape }}">
</temba-textinput>
</div>
{% if form.token.errors %}
<temba-alert level="error" class="mt-4">
{{ form.token.errors }}
</temba-alert>
{% endif %}
{% if form.token.errors %}<div class="alert alert-error mt-4">{{ form.token.errors }}</div>{% endif %}
<div class="mt-2 text-right">
<a href="{% url 'users.two_factor_verify' %}">{% trans "Use Device" %}</a>
</div>
Expand Down
6 changes: 1 addition & 5 deletions templates/orgs/login/two_factor_verify.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
<div class="mt-4">
<input name="otp" maxlength="6" placeholder="{{ _("6-digit code") |escape }}" class="input">
</div>
{% if form.otp.errors %}
<temba-alert level="error" class="mt-4">
{{ form.otp.errors }}
</temba-alert>
{% endif %}
{% if form.otp.errors %}<div class="alert alert-error mt-4">{{ form.otp.errors }}</div>{% endif %}
<div class="mt-2 text-right">
<a href="{% url 'users.two_factor_backup' %}">{% trans "Use Backup Token" %}</a>
</div>
Expand Down

0 comments on commit 5a0384b

Please sign in to comment.