diff --git a/src/authentic2/a2_rbac/models.py b/src/authentic2/a2_rbac/models.py
index 4c7438128..f729c60f4 100644
--- a/src/authentic2/a2_rbac/models.py
+++ b/src/authentic2/a2_rbac/models.py
@@ -18,7 +18,7 @@ from collections import namedtuple
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator
from django.utils import six
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import ugettext_lazy as _, pgettext_lazy
from django.utils.text import slugify
from django.db import models
from django.contrib.contenttypes.models import ContentType
@@ -423,9 +423,9 @@ GenericRelation(Permission,
CHANGE_PASSWORD_OP = Operation(name=_('Change password'), slug='change_password')
-RESET_PASSWORD_OP = Operation(name=_('Reset password'), slug='reset_password')
-ACTIVATE_OP = Operation(name=_('Activate'), slug='activate')
-CHANGE_EMAIL_OP = Operation(name=_('Change email'), slug='change_email')
+RESET_PASSWORD_OP = Operation(name=_('Password reset'), slug='reset_password')
+ACTIVATE_OP = Operation(name=_('Activation'), slug='activate')
+CHANGE_EMAIL_OP = Operation(name=pgettext_lazy('operation', 'Change email'), slug='change_email')
MANAGE_MEMBERS_OP = Operation(name=_('Manage role members'), slug='manage_members')
MANAGE_AUTHORIZATIONS_OP = Operation(
name=_('Manage service consents'), slug='manage_authorizations')
diff --git a/src/authentic2/apps/journal/search_engine.py b/src/authentic2/apps/journal/search_engine.py
index b58cf1519..5b492c5bf 100644
--- a/src/authentic2/apps/journal/search_engine.py
+++ b/src/authentic2/apps/journal/search_engine.py
@@ -80,12 +80,12 @@ class SearchEngine:
if not hasattr(self, method_name):
return
- yield from getattr(self, method_name)(lexem[len(prefix) + 1 :])
+ yield from getattr(self, method_name)(lexem[len(prefix) + 1:])
@classmethod
def documentation(cls):
- yield _('You can use quote around to preserve spaces.')
- yield _('You can use colon terminated prefixes to make special searches.')
+ yield _('You can use colon terminated prefixes to make special searches, '
+ 'and you can use quote around the suffix to preserve spaces.')
for name in dir(cls):
documentation = getattr(getattr(cls, name), 'documentation', None)
if documentation:
@@ -126,11 +126,11 @@ to users with this email address..'''
)
def search_by_username(self, lexem):
- users = User.objects.filter(username__startswith=lexem)
- yield (self.query_for_users(users) | Q(data__username__startswith=lexem.lower()))
+ users = User.objects.filter(username__iexact=lexem)
+ yield (self.query_for_users(users) | Q(data__username__iexact=lexem.lower()))
search_by_username.documentation = _(
'''\
You can use username:john to find all events related \
-to users whose username starts with john.'''
+to users whose username is john.'''
)
diff --git a/src/authentic2/journal_event_types.py b/src/authentic2/journal_event_types.py
index 3b11279bf..77391fe5f 100644
--- a/src/authentic2/journal_event_types.py
+++ b/src/authentic2/journal_event_types.py
@@ -50,11 +50,11 @@ def login_method_label(how):
if how.startswith('password'):
return _('password')
elif how == 'fc':
- return _('FranceConnect')
+ return 'FranceConnect'
elif how == 'saml':
- return _('SAML')
+ return 'SAML'
elif how == 'oidc':
- return _('OpenIDConnect')
+ return 'OpenIDConnect'
elif how:
return how
else:
@@ -212,7 +212,7 @@ class UserEdit(EventTypeWithService):
class UserDeletion(EventTypeWithService):
name = 'user.deletion'
- label = _('deletion')
+ label = _('user deletion')
@classmethod
def record(cls, user, session, service):
@@ -235,7 +235,7 @@ class UserServiceSSO(EventTypeWithService):
class UserServiceSSOAuthorization(EventTypeWithService):
name = 'user.service.sso.authorization'
- label = _('consentment to single sign on')
+ label = _('consent to single sign on')
@classmethod
def record(cls, user, session, service, **kwargs):
@@ -249,7 +249,7 @@ class UserServiceSSOAuthorization(EventTypeWithService):
class UserServiceSSOUnauthorization(EventTypeWithService):
name = 'user.service.sso.unauthorization'
- label = _('remove consentment to single sign on')
+ label = _('remove consent to single sign on')
@classmethod
def record(cls, user, session, service):
diff --git a/src/authentic2/manager/journal_event_types.py b/src/authentic2/manager/journal_event_types.py
index 82459e991..5e3fa34c6 100644
--- a/src/authentic2/manager/journal_event_types.py
+++ b/src/authentic2/manager/journal_event_types.py
@@ -248,11 +248,12 @@ class ManagerUserSSOAuthorizationDeletion(EventTypeWithService):
__, user = event.get_typed_references(None, User)
service_name = cls.get_service_name(event)
if context and context == user:
- return _('deletion of authorization of single sign on with "%s" by administrator') % service_name
+ return _('deletion of authorization of single sign on with "{service}" by administrator').format(
+ service=service_name)
elif user:
- return _('deletion of authorization of single sign on with "%s" of user "%s"') % (
- service_name,
- user.get_full_name(),
+ return _('deletion of authorization of single sign on with "{service}" of user "{user}"').format(
+ service=service_name,
+ user=user.get_full_name(),
)
return super().get_message(event, context)
@@ -264,7 +265,7 @@ class RoleEventsMixin(EventTypeDefinition):
references = [role] + references
data = data or {}
data.update(
- {'role_name': str(role), 'role_uuid': role.uuid,}
+ {'role_name': str(role), 'role_uuid': role.uuid}
)
super().record(
user=user, session=session, references=references, data=data,
@@ -300,9 +301,9 @@ class ManagerRoleEdit(RoleEventsMixin):
new = event.get_data('new')
edited_attributes = ', '.join(get_attributes_label(new)) or ''
if context != role:
- return _('edit of role "%s" (%s)') % (role, edited_attributes)
+ return _('edit of role "{role}" ({change})').format(role=role, change=edited_attributes)
else:
- return _('edit (%s)') % edited_attributes
+ return _('edit ({change})').format(change=edited_attributes)
class ManagerRoleDeletion(RoleEventsMixin):
diff --git a/src/authentic2/templates/authentic2/api_user_create_registration_email_body.txt b/src/authentic2/templates/authentic2/api_user_create_registration_email_body.txt
index e8fe7cc60..29e5c1945 100644
--- a/src/authentic2/templates/authentic2/api_user_create_registration_email_body.txt
+++ b/src/authentic2/templates/authentic2/api_user_create_registration_email_body.txt
@@ -1,4 +1,4 @@
-{% load i18n %}{% blocktrans with hostname=request.get_host %}A new account was created for you on {{ hostname }}{% endblocktrans %}
+{% load i18n %}{% blocktrans with hostname=request.get_host context "api" %}A new account was created for you on {{ hostname }}{% endblocktrans %}
{% if data.username %}
{% trans "Username" %} : {{ data.username }}{% endif %}
{% trans "Email" %} : {{ data.email }}
diff --git a/src/authentic2/templates/authentic2/api_user_create_registration_email_subject.txt b/src/authentic2/templates/authentic2/api_user_create_registration_email_subject.txt
index e68499009..fe40c26b2 100644
--- a/src/authentic2/templates/authentic2/api_user_create_registration_email_subject.txt
+++ b/src/authentic2/templates/authentic2/api_user_create_registration_email_subject.txt
@@ -1 +1 @@
-{% load i18n %}{% blocktrans with hostname=request.get_host %}Your account was created on {{ hostname }}{% endblocktrans %}
+{% load i18n %}{% blocktrans with hostname=request.get_host context "api" %}Your account was created on {{ hostname }}{% endblocktrans %}
diff --git a/tests/test_manager_journal.py b/tests/test_manager_journal.py
index 6c2ea0a7e..d637ccc4c 100644
--- a/tests/test_manager_journal.py
+++ b/tests/test_manager_journal.py
@@ -305,7 +305,7 @@ def test_global_journal(app, superuser, events):
'user': 'Johnny doe',
},
{
- 'message': 'deletion',
+ 'message': 'user deletion',
'timestamp': 'Jan. 1, 2020, 11 a.m.',
'type': 'user.deletion',
'user': 'Johnny doe',
@@ -532,7 +532,7 @@ def test_user_journal(app, superuser, events):
'user': 'Johnny doe',
},
{
- 'message': 'deletion',
+ 'message': 'user deletion',
'timestamp': 'Jan. 1, 2020, 11 a.m.',
'type': 'user.deletion',
'user': 'Johnny doe',