Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified style and accessibility upgrades for login, registration, and profile pages #4491

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/core/locales/cy/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ msgstr ""

#: src/core/views.py:355
msgid ""
"Your account has been created, please follow theinstructions in the email "
"Your account has been created. Please follow the instructions in the email "
"that has been sent to you."
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion src/core/locales/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ msgstr "Falls Ihr Konto gefunden wurde, wurde Ihnen eine E-Mail geschickt."

#: src/core/views.py:355
msgid ""
"Your account has been created, please follow theinstructions in the email "
"Your account has been created. Please follow the instructions in the email "
"that has been sent to you."
msgstr ""
"Ihr Konto wurde angelegt. Bitte folgen Sie den Anweisungen aus der E-Mail, "
Expand Down
2 changes: 1 addition & 1 deletion src/core/locales/en_us/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ msgstr ""

#: src/core/views.py:355
msgid ""
"Your account has been created, please follow theinstructions in the email "
"Your account has been created. Please follow the instructions in the email "
"that has been sent to you."
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion src/core/locales/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4440,7 +4440,7 @@ msgid "\n"
msgstr ""

#: src/core/views.py:355
msgid "Your account has been created, please follow theinstructions in the email that has been sent to you."
msgid "Your account has been created. Please follow the instructions in the email that has been sent to you."
msgstr ""

#: src/core/views.py:400
Expand Down
2 changes: 1 addition & 1 deletion src/core/locales/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ msgstr ""

#: src/core/views.py:355
msgid ""
"Your account has been created, please follow theinstructions in the email "
"Your account has been created. Please follow the instructions in the email "
"that has been sent to you."
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion src/core/locales/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ msgstr ""

#: src/core/views.py:355
msgid ""
"Your account has been created, please follow theinstructions in the email "
"Your account has been created. Please follow the instructions in the email "
"that has been sent to you."
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion src/core/locales/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ msgstr ""

#: src/core/views.py:355
msgid ""
"Your account has been created, please follow theinstructions in the email "
"Your account has been created. Please follow the instructions in the email "
"that has been sent to you."
msgstr ""

Expand Down
99 changes: 99 additions & 0 deletions src/core/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
__copyright__ = "Copyright 2024 Birkbeck, University of London"
__author__ = "Open Library of Humanities"
__license__ = "AGPL v3"
__maintainer__ = "Open Library of Humanities"

from mock import patch
from uuid import uuid4

from django.test import Client, TestCase, override_settings

from utils.testing import helpers

from core import models as core_models


class CoreViewTestsWithData(TestCase):

@classmethod
def setUpTestData(cls):
cls.press = helpers.create_press()
cls.journal_one, cls.journal_two = helpers.create_journals()
helpers.create_roles(['author'])
cls.user_email = '[email protected]'
cls.user_password = 'xUMXW1oXn2l8L26Kixi2'
cls.user = core_models.Account.objects.create_user(
cls.user_email,
password=cls.user_password,
)
cls.user.confirmation_code = uuid4()
cls.user.is_active = True
cls.user_orcid = 'https://orcid.org/0000-0001-2345-6789'
cls.user.orcid = cls.user_orcid
cls.orcid_token_uuid = uuid4()
cls.orcid_token = core_models.OrcidToken.objects.create(
token=cls.orcid_token_uuid,
orcid=cls.user_orcid,
)
cls.reset_token_uuid = uuid4()
cls.reset_token = core_models.PasswordResetToken.objects.create(
account=cls.user,
token=cls.reset_token_uuid,
)
cls.user.save()

def setUp(self):
self.client = Client()


class AccountManagementTemplateTests(CoreViewTestsWithData):

def test_user_login(self):
url = '/login/'
data = {}
template = 'admin/core/accounts/login.html'
response = self.client.get(url, data)
self.assertTemplateUsed(response, template)

def test_get_reset_token(self):
url = '/reset/step/1/'
data = {}
template = 'admin/core/accounts/get_reset_token.html'
response = self.client.get(url, data)
self.assertTemplateUsed(response, template)

def test_reset_password(self):
url = f'/reset/step/2/{self.reset_token_uuid}/'
data = {}
template = 'admin/core/accounts/reset_password.html'
response = self.client.get(url, data)
self.assertTemplateUsed(response, template)

def test_register(self):
url = '/register/step/1/'
data = {}
template = 'admin/core/accounts/register.html'
response = self.client.get(url, data)
self.assertTemplateUsed(response, template)

def test_orcid_registration(self):
url = f'/register/step/orcid/{self.orcid_token_uuid}/'
data = {}
template = 'admin/core/accounts/orcid_registration.html'
response = self.client.get(url, data)
self.assertTemplateUsed(response, template)

def test_activate_account(self):
url = f'/register/step/2/{self.user.confirmation_code}/'
data = {}
template = 'admin/core/accounts/activate_account.html'
response = self.client.get(url, data)
self.assertTemplateUsed(response, template)

def test_edit_profile(self):
self.client.login(username=self.user_email, password=self.user_password)
url = '/profile/'
data = {}
template = 'admin/core/accounts/edit_profile.html'
response = self.client.get(url, data)
self.assertTemplateUsed(response, template)
16 changes: 8 additions & 8 deletions src/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def user_login(request):
context = {
'form': form,
}
template = 'core/login.html'
template = 'admin/core/accounts/login.html'

return render(request, template, context)

Expand Down Expand Up @@ -255,7 +255,7 @@ def get_reset_token(request):
except models.Account.DoesNotExist:
return redirect(reverse('core_login'))

template = 'core/accounts/get_reset_token.html'
template = 'admin/core/accounts/get_reset_token.html'
context = {
'new_reset_token': new_reset_token,
'form': form,
Expand Down Expand Up @@ -297,7 +297,7 @@ def reset_password(request, token):
messages.add_message(request, messages.SUCCESS, 'Your password has been reset.')
return redirect(reverse('core_login'))

template = 'core/accounts/reset_password.html'
template = 'admin/core/accounts/reset_password.html'
context = {
'reset_token': reset_token,
'form': form,
Expand Down Expand Up @@ -374,12 +374,12 @@ def register(request):

messages.add_message(
request, messages.SUCCESS,
_('Your account has been created, please follow the'
_('Your account has been created. Please follow the '
'instructions in the email that has been sent to you.'),
)
return redirect(reverse('core_login'))

template = 'core/accounts/register.html'
template = 'admin/core/accounts/register.html'
context["form"] = form

return render(request, template, context)
Expand All @@ -388,7 +388,7 @@ def register(request):
def orcid_registration(request, token):
token = get_object_or_404(models.OrcidToken, token=token, expiry__gt=timezone.now())

template = 'core/accounts/orcid_registration.html'
template = 'admin/core/accounts/orcid_registration.html'
context = {
'token': token,
}
Expand Down Expand Up @@ -422,7 +422,7 @@ def activate_account(request, token):

return redirect(reverse('core_login'))

template = 'core/accounts/activate_account.html'
template = 'admin/core/accounts/activate_account.html'
context = {
'account': account,
}
Expand Down Expand Up @@ -540,7 +540,7 @@ def edit_profile(request):
elif 'export' in request.POST:
return logic.export_gdpr_user_profile(user)

template = 'core/accounts/edit_profile.html'
template = 'admin/core/accounts/edit_profile.html'
context = {
'form': form,
'staff_group_membership_form': staff_group_membership_form,
Expand Down
11 changes: 11 additions & 0 deletions src/static/admin/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -941,3 +941,14 @@ ul.menu {
}
}
}

.orcid-button {
color: var(--clr-black);
border: 1px solid var(--clr-orcid);
background-color: var(--clr-white);
}
.orcid-button:hover, .orcid-button:focus {
joemull marked this conversation as resolved.
Show resolved Hide resolved
color: var(--clr-black);
border: 1px solid var(--clr-orcid);
background-color: var(--clr-orcid-light);
}
8 changes: 5 additions & 3 deletions src/static/admin/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1511,11 +1511,12 @@ h6 {

a {
line-height: inherit;
color: #5a98e5;
color: var(--clr-blue-medium);
text-decoration: none;
cursor: pointer; }
a:hover, a:focus {
color: #3380df; }
color: var(--clr-navy);
}
a img {
border: 0; }

Expand Down Expand Up @@ -2216,7 +2217,8 @@ select {
content: "/";
color: #b7bac0; }
.breadcrumbs a {
color: #5a98e5; }
color: var(--clr-blue-medium);
}
.breadcrumbs a:hover {
text-decoration: underline; }
.breadcrumbs .disabled {
Expand Down
3 changes: 2 additions & 1 deletion src/static/admin/css/index.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* A single file to collect CSS for the back-office UI */

@import "admin.css";
@import "settings.css";
@import "app.css";
@import "admin.css";
16 changes: 16 additions & 0 deletions src/static/admin/css/settings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* This file resets some things for accessibility in the back-office UI
* and can also be expanded to hold other global variables */

:root {

/* Back-office named colors */
--clr-blue-medium: #305AA3;
--clr-navy: #1a2a57;
--clr-black: #0a0a0a;
--clr-white: #fff;

/* Third-party named colors */
--clr-orcid: rgb(68, 116, 5);
--clr-orcid-light: rgb(245, 249, 232);

}
10 changes: 1 addition & 9 deletions src/static/common/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,6 @@ article .list-romanlower {
article .list-romanupper {
list-style-type: upper-roman;
}
.orcid-button {
background-color: rgb(166, 206, 57);
color: #fff;
}
.orcid-button:hover, .orcid-button:focus {
background-color: rgb(138, 178, 22);
color: #fff;
}
.no-list-type {
list-style-type: none !important;
}
Expand Down Expand Up @@ -334,4 +326,4 @@ a.twitter-x{
font-size: large;
font-weight: bold;
line-height: 1.25;
}
}
31 changes: 28 additions & 3 deletions src/static/common/css/utilities.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,31 @@
.column-gap-5 { column-gap: 5rem; }
.column-gap-6 { column-gap: 6rem; }

/* Content-based width */
.width-min-content { width: min-content };
.width-max-content { width: max-content };
/* Width */
.max-w-8 { max-width: 8rem; }
.max-w-12 { max-width: 12rem; }
.max-w-16 { max-width: 16rem; }
.max-w-20 { max-width: 20rem; }
.max-w-24 { max-width: 24rem; }
.max-w-28 { max-width: 28rem; }
.max-w-32 { max-width: 32rem; }
.max-w-40 { max-width: 40rem; }
.max-w-48 { max-width: 48rem; }
.max-w-56 { max-width: 56rem; }
.max-w-64 { max-width: 64rem; }
.max-w-72 { max-width: 72rem; }
.max-w-80 { max-width: 80rem; }
.width-min-content { width: min-content; }
.width-max-content { width: max-content; }

/* Padding */
.padding-inline-0 { padding-inline: 0rem; }
.padding-inline-1 { padding-inline: 1rem; }
.padding-inline-2 { padding-inline: 2rem; }
.padding-inline-3 { padding-inline: 3rem; }
.padding-inline-4 { padding-inline: 4rem; }
.padding-block-0 { padding-block: 0rem; }
.padding-block-1 { padding-block: 1rem; }
.padding-block-2 { padding-block: 2rem; }
.padding-block-3 { padding-block: 3rem; }
.padding-block-4 { padding-block: 4rem; }
42 changes: 42 additions & 0 deletions src/templates/admin/core/accounts/activate_account.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% extends "admin/core/small_form.html" %}
{% load i18n foundation %}

{% block contextual_title %}
{% trans "Activate Account" %}
{% endblock contextual_title %}

{% block breadcrumbs %}
{{ block.super }}
<li>{% trans "Activate Account" %}</li>
{% endblock breadcrumbs %}

{% block title-section %}
{% if account %}
{% trans "Activate Account" %}
{% else %}
{% trans "No account to activate" %}
{% endif %}
{% endblock %}

{% block form_content %}
{% if account %}
{% include "admin/elements/forms/messages_in_callout.html" with form=form %}
<p>{% blocktrans %}
You can complete the activation process by clicking the button
below.
{% endblocktrans %}</p>
<button class="button secondary expanded" name="activate">
{% trans "Activate Account" %}
</button>
{% else %}
<p>{% blocktrans %}
Sorry, we could not find an account to activate, or your account is active
already. You can check if it is active by attempting to log in.
{% endblocktrans %}</p>
<div>
<a class="button secondary expanded" href="{% url 'core_login' %}">
{% trans "Log in" %}
</a>
</div>
{% endif %}
{% endblock form_content %}
Loading