Skip to content

Commit e3577f0

Browse files
committed
[chores] Updated admin login template username label
Mention that it's now possible to login using the email or the phone number (provided the authentication backend is correctly set as indicated in the README). Added also a test for the features of the custom login.html admin template.
1 parent cad3b53 commit e3577f0

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,8 @@ Add ``openwisp_utils.staticfiles.DependencyFinder`` to
668668
5. Add ``openwisp_utils.loaders.DependencyLoader``
669669
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
670670

671-
Add ``openwisp_utils.loaders.DependencyLoader`` to ``TEMPLATES`` in your ``settings.py``:
671+
Add ``openwisp_utils.loaders.DependencyLoader`` to ``TEMPLATES``
672+
before ``django.template.loaders.app_directories.Loader`` in your ``settings.py``:
672673

673674
.. code-block:: python
674675
@@ -678,8 +679,8 @@ Add ``openwisp_utils.loaders.DependencyLoader`` to ``TEMPLATES`` in your ``setti
678679
'OPTIONS': {
679680
'loaders': [
680681
'django.template.loaders.filesystem.Loader',
681-
'django.template.loaders.app_directories.Loader',
682682
'openwisp_utils.loaders.DependencyLoader',
683+
'django.template.loaders.app_directories.Loader',
683684
],
684685
'context_processors': [
685686
'django.template.context_processors.debug',

openwisp_users/templates/admin/login.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "admin/login.html" %}
2+
{% load i18n %}
23
{% block content %}
34
{% if form.errors and not form.non_field_errors %}
45
<p class="errornote">
@@ -28,7 +29,10 @@
2829
<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
2930
<div class="form-row">
3031
{{ form.username.errors }}
31-
{{ form.username.label_tag }} {{ form.username }}
32+
<label class="required" for="id_username">
33+
{% trans 'Email, phone number or username' %}:
34+
</label>
35+
{{ form.username }}
3236
</div>
3337
<div class="form-row">
3438
{{ form.password.errors }}

openwisp_users/tests/test_admin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,18 @@ def test_delete_inline_org_user(self):
14791479
def test_delete_inline_owner_org_user(self):
14801480
self._delete_inline_org_user(is_admin=True)
14811481

1482+
def test_login_page(self):
1483+
r = self.client.get(reverse('admin:login'))
1484+
1485+
with self.subTest('Test forgot password link'):
1486+
self.assertContains(
1487+
r, '<a href="/accounts/password/reset/">Forgot Password?</a>'
1488+
)
1489+
1490+
with self.subTest('Test username label'):
1491+
self.assertContains(r, '<label class="required" for="id_username">')
1492+
self.assertContains(r, 'Email, phone number or username:')
1493+
14821494

14831495
class TestMultitenantAdmin(TestMultitenantAdminMixin, TestOrganizationMixin, TestCase):
14841496
app_label = 'openwisp_users'

tests/openwisp2/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
'OPTIONS': {
7777
'loaders': [
7878
'django.template.loaders.filesystem.Loader',
79-
'django.template.loaders.app_directories.Loader',
8079
'openwisp_utils.loaders.DependencyLoader',
80+
'django.template.loaders.app_directories.Loader',
8181
],
8282
'context_processors': [
8383
'django.template.context_processors.debug',

0 commit comments

Comments
 (0)