Skip to content

Commit 1a3c78c

Browse files
committed
Do not use custom password template for wagtail admin.
1 parent 3f6fd48 commit 1a3c78c

2 files changed

Lines changed: 44 additions & 34 deletions

File tree

hypha/apply/users/forms.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ def __init__(self, *args, **kwargs):
102102
attrs={"value": "Not used - see full_name"}
103103
)
104104

105+
for field_name in ("password1", "password2"):
106+
if field_name in self.fields:
107+
self.fields[field_name].widget.attrs["data_plain"] = True
108+
105109

106110
class GroupsModelMultipleChoiceField(forms.ModelMultipleChoiceField):
107111
"""
Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
{% load i18n %}
22

3-
<div class="input validator" x-data="{ showPassword: false }" x-id="['toggle-help']">
4-
<input
5-
type="{{ widget.type }}"
6-
:type="showPassword ? 'text' : 'password'"
7-
:autocomplete="showPassword ? 'off' : 'current-password'"
8-
name="{{ widget.name }}"
9-
{% if widget.value != None %}value="{{ widget.value|stringformat:'s' }}"{% endif %}
10-
{% include 'django/forms/widgets/attrs.html' %}
11-
:aria-describedby="$id('toggle-help')"
12-
/>
13-
<div
14-
class="opacity-50 cursor-pointer hover:opacity-80"
15-
role="button"
16-
tabindex="0"
17-
:aria-label="showPassword ? '{% trans "Hide password" %}' : '{% trans "Show password" %}'"
18-
x-bind:title="showPassword ? '{% trans "Hide password" %}' : '{% trans "Show password" %}'"
19-
:aria-pressed="showPassword.toString()"
20-
@click.prevent="showPassword = !showPassword"
21-
@keydown.enter.prevent="showPassword = !showPassword"
22-
@keydown.space.prevent="showPassword = !showPassword"
23-
>
24-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"
25-
fill="currentColor"
26-
class="size-4"
27-
aria-hidden="true"
3+
{% if widget.attrs.data_plain %}
4+
{% include "django/forms/widgets/input.html" %}
5+
{% else %}
6+
<div class="input validator" x-data="{ showPassword: false }" x-id="['toggle-help']">
7+
<input
8+
type="{{ widget.type }}"
9+
:type="showPassword ? 'text' : 'password'"
10+
:autocomplete="showPassword ? 'off' : 'current-password'"
11+
name="{{ widget.name }}"
12+
{% if widget.value != None %}value="{{ widget.value|stringformat:'s' }}"{% endif %}
13+
{% include 'django/forms/widgets/attrs.html' %}
14+
:aria-describedby="$id('toggle-help')"
15+
/>
16+
<div
17+
class="opacity-50 cursor-pointer hover:opacity-80"
18+
role="button"
19+
tabindex="0"
20+
:aria-label="showPassword ? '{% trans "Hide password" %}' : '{% trans "Show password" %}'"
21+
x-bind:title="showPassword ? '{% trans "Hide password" %}' : '{% trans "Show password" %}'"
22+
:aria-pressed="showPassword.toString()"
23+
@click.prevent="showPassword = !showPassword"
24+
@keydown.enter.prevent="showPassword = !showPassword"
25+
@keydown.space.prevent="showPassword = !showPassword"
2826
>
29-
<path x-show="!showPassword" d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" />
30-
<path x-show="!showPassword" fill-rule="evenodd" d="M1.38 8.28a.87.87 0 0 1 0-.566 7.003 7.003 0 0 1 13.238.006.87.87 0 0 1 0 .566A7.003 7.003 0 0 1 1.379 8.28ZM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" clip-rule="evenodd" />
31-
<path x-show="showPassword" fill-rule="evenodd" d="M3.28 2.22a.75.75 0 0 0-1.06 1.06l10.5 10.5a.75.75 0 1 0 1.06-1.06l-1.322-1.323a7.012 7.012 0 0 0 2.16-3.11.87.87 0 0 0 0-.567A7.003 7.003 0 0 0 4.82 3.76l-1.54-1.54Zm3.196 3.195 1.135 1.136A1.502 1.502 0 0 1 9.45 8.389l1.136 1.135a3 3 0 0 0-4.109-4.109Z" clip-rule="evenodd" />
32-
<path x-show="showPassword" d="m7.812 10.994 1.816 1.816A7.003 7.003 0 0 1 1.38 8.28a.87.87 0 0 1 0-.566 6.985 6.985 0 0 1 1.113-2.039l2.513 2.513a3 3 0 0 0 2.806 2.806Z" />
33-
</svg>
27+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"
28+
fill="currentColor"
29+
width="16"
30+
height="16"
31+
class="size-4"
32+
aria-hidden="true"
33+
>
34+
<path x-show="!showPassword" d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" />
35+
<path x-show="!showPassword" fill-rule="evenodd" d="M1.38 8.28a.87.87 0 0 1 0-.566 7.003 7.003 0 0 1 13.238.006.87.87 0 0 1 0 .566A7.003 7.003 0 0 1 1.379 8.28ZM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" clip-rule="evenodd" />
36+
<path x-show="showPassword" fill-rule="evenodd" d="M3.28 2.22a.75.75 0 0 0-1.06 1.06l10.5 10.5a.75.75 0 1 0 1.06-1.06l-1.322-1.323a7.012 7.012 0 0 0 2.16-3.11.87.87 0 0 0 0-.567A7.003 7.003 0 0 0 4.82 3.76l-1.54-1.54Zm3.196 3.195 1.135 1.136A1.502 1.502 0 0 1 9.45 8.389l1.136 1.135a3 3 0 0 0-4.109-4.109Z" clip-rule="evenodd" />
37+
<path x-show="showPassword" d="m7.812 10.994 1.816 1.816A7.003 7.003 0 0 1 1.38 8.28a.87.87 0 0 1 0-.566 6.985 6.985 0 0 1 1.113-2.039l2.513 2.513a3 3 0 0 0 2.806 2.806Z" />
38+
</svg>
3439

35-
<span :id="$id('toggle-help')" class="sr-only">
36-
<span x-text="showPassword ? '{% trans "Password is currently visible" %}' : '{% trans "Password is currently hidden" %}'"></span>
37-
</span>
40+
<span :id="$id('toggle-help')" class="sr-only">
41+
<span x-text="showPassword ? '{% trans "Password is currently visible" %}' : '{% trans "Password is currently hidden" %}'"></span>
42+
</span>
43+
</div>
3844
</div>
39-
</div>
45+
{% endif %}

0 commit comments

Comments
 (0)