Skip to content

Commit

Permalink
feat: form errors template
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav committed Sep 15, 2022
1 parent 4daee46 commit 3ddda39
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 61 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ Note: In case that it is needed to pass custom variables into dashboard tamplate

## Unfold Development

### Pre-commit

Before adding any source code, it is recommended to have pre-commit installed on your local computer to check for all potential issues when comitting the code.

```bash
pip install pre-commit
pre-commit install
pre-commit install --hook-type commit-msg
```

### Poetry Configuration

To add a new feature or fix the easiest approach is to use django-unfold in combination with Poetry. The process looks like:
Expand Down
26 changes: 2 additions & 24 deletions src/unfold/templates/admin/auth/user/change_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,7 @@

{{ form.password1 }}

{{ form.password1.errors }}

{% if form.password1.errors %}
<div class="mt-1 text-red-600 text-sm">
<ul>
{% for error in form.password1.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% include "unfold/helpers/form_errors.html" with errors=form.password1.errors %}

{% if form.password1.help_text %}
<div class="leading-relaxed mt-2 text-gray-500 text-xs">
Expand All @@ -89,17 +77,7 @@

{{ form.password2 }}

{% if form.password2.errors %}
<div class="mt-1 text-red-600 text-sm">
<ul>
{% for error in form.password2.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% include "unfold/helpers/form_errors.html" with errors=form.password2.errors %}

{% if form.password2.help_text %}
<div class="leading-relaxed mt-2 text-gray-500 text-xs">
Expand Down
40 changes: 3 additions & 37 deletions src/unfold/templates/registration/password_change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,7 @@

{{ form.old_password }}

{{ form.old_password.errors }}

{% if form.old_password.errors %}
<div class="mt-1 text-red-600 text-sm">
<ul>
{% for error in form.old_password.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% include "unfold/helpers/form_errors.html" with errors=form.old_password.errors %}

{% if form.old_password.help_text %}
<div class="leading-relaxed mt-2 text-gray-500 text-xs">
Expand All @@ -79,19 +67,7 @@

{{ form.new_password1 }}

{{ form.new_password1.errors }}

{% if form.new_password1.errors %}
<div class="mt-1 text-red-600 text-sm">
<ul>
{% for error in form.new_password1.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% include "unfold/helpers/form_errors.html" with errors=form.new_password1.errors %}

{% if form.new_password1.help_text %}
<div class="leading-relaxed mt-2 text-gray-500 text-xs">
Expand All @@ -107,17 +83,7 @@

{{ form.new_password2 }}

{% if form.new_password2.errors %}
<div class="mt-1 text-red-600 text-sm">
<ul>
{% for error in form.new_password2.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% include "unfold/helpers/form_errors.html" with errors=form.new_password2.errors %}

{% if form.new_password2.help_text %}
<div class="leading-relaxed mt-2 text-gray-500 text-xs">
Expand Down
11 changes: 11 additions & 0 deletions src/unfold/templates/unfold/helpers/form_errors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% if errors %}
<div class="mt-1 text-red-600 text-sm">
<ul>
{% for error in errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}

0 comments on commit 3ddda39

Please sign in to comment.