From 75913c92ea6356a46dcab7f59fec63de340007fc Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 6 Oct 2022 23:10:24 +0200 Subject: [PATCH] misc: replace deprecated ugettext by gettext (#69974) --- debian/multitenant/debian_config.py | 2 +- src/authentic2/a2_rbac/management.py | 10 +++++----- src/authentic2/a2_rbac/signal_handlers.py | 2 +- src/authentic2/apps/authenticators/forms.py | 2 +- src/authentic2/apps/authenticators/models.py | 2 +- src/authentic2/apps/authenticators/views.py | 2 +- src/authentic2/apps/journal/forms.py | 2 +- src/authentic2/apps/journal/search_engine.py | 2 +- src/authentic2/attributes_ng/engine.py | 2 +- src/authentic2/attributes_ng/sources/django_user.py | 2 +- src/authentic2/attributes_ng/sources/service_roles.py | 2 +- src/authentic2/backends/ldap_backend.py | 2 +- src/authentic2/csv_import.py | 2 +- src/authentic2/custom_user/apps.py | 2 +- src/authentic2/data_transfer.py | 2 +- src/authentic2/disco_service/disco_responder.py | 2 +- src/authentic2/forms/authentication.py | 8 ++++---- src/authentic2/forms/fields.py | 2 +- src/authentic2/forms/mixins.py | 2 +- src/authentic2/forms/passwords.py | 2 +- src/authentic2/forms/registration.py | 6 +++--- src/authentic2/forms/widgets.py | 2 +- src/authentic2/hashers.py | 2 +- src/authentic2/idp/saml/backend.py | 2 +- src/authentic2/idp/saml/saml2_endpoints.py | 4 ++-- src/authentic2/idp/saml/views.py | 2 +- src/authentic2/journal_event_types.py | 2 +- src/authentic2/manager/forms.py | 7 ++++--- src/authentic2/manager/journal_views.py | 2 +- src/authentic2/manager/ou_views.py | 2 +- src/authentic2/manager/role_views.py | 2 +- src/authentic2/manager/service_views.py | 2 +- src/authentic2/manager/tables.py | 8 ++++---- src/authentic2/manager/user_import.py | 2 +- src/authentic2/manager/user_views.py | 11 ++++++----- src/authentic2/manager/views.py | 2 +- src/authentic2/middleware.py | 2 +- src/authentic2/passwords.py | 2 +- src/authentic2/saml/admin.py | 2 +- src/authentic2/saml/forms.py | 2 +- src/authentic2/saml/management/commands/mapping.py | 2 +- src/authentic2/urls.py | 2 +- src/authentic2/utils/evaluate.py | 2 +- src/authentic2/utils/template.py | 2 +- src/authentic2/views.py | 2 +- src/authentic2_auth_fc/forms.py | 2 +- src/authentic2_auth_fc/utils.py | 2 +- src/authentic2_auth_fc/views.py | 2 +- src/authentic2_auth_oidc/utils.py | 2 +- src/authentic2_auth_oidc/views.py | 2 +- src/authentic2_auth_saml/adapters.py | 2 +- .../migrations/0003_auto_20220726_1713.py | 2 +- src/authentic2_idp_cas/admin.py | 2 +- src/authentic2_idp_oidc/manager/views.py | 2 +- src/authentic2_idp_oidc/views.py | 2 +- src/django_rbac/models.py | 2 +- tests/test_all.py | 2 +- 57 files changed, 78 insertions(+), 76 deletions(-) diff --git a/debian/multitenant/debian_config.py b/debian/multitenant/debian_config.py index 42394c1f..d71c8b7c 100644 --- a/debian/multitenant/debian_config.py +++ b/debian/multitenant/debian_config.py @@ -1,6 +1,6 @@ import os -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ # Debian defaults DEBUG = False diff --git a/src/authentic2/a2_rbac/management.py b/src/authentic2/a2_rbac/management.py index 08044ed0..85b40a98 100644 --- a/src/authentic2/a2_rbac/management.py +++ b/src/authentic2/a2_rbac/management.py @@ -16,8 +16,8 @@ from django.contrib.contenttypes.models import ContentType from django.utils.text import slugify -from django.utils.translation import ugettext -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext +from django.utils.translation import gettext_lazy as _ from authentic2.a2_rbac.models import OrganizationalUnit, Role from authentic2.utils.misc import get_fk_model @@ -106,10 +106,10 @@ def update_content_types_roles(): if app_settings.MANAGED_CONTENT_TYPES == (): Role.objects.filter(slug=slug).delete() else: - admin_role, created = Role.objects.get_or_create(slug=slug, defaults=dict(name=ugettext('Manager'))) + admin_role, created = Role.objects.get_or_create(slug=slug, defaults=dict(name=gettext('Manager'))) admin_role.add_self_administration() - if not created and admin_role.name != ugettext('Manager'): - admin_role.name = ugettext('Manager') + if not created and admin_role.name != gettext('Manager'): + admin_role.name = gettext('Manager') admin_role.save() for ct in cts: diff --git a/src/authentic2/a2_rbac/signal_handlers.py b/src/authentic2/a2_rbac/signal_handlers.py index 2c83828e..efebbea7 100644 --- a/src/authentic2/a2_rbac/signal_handlers.py +++ b/src/authentic2/a2_rbac/signal_handlers.py @@ -17,8 +17,8 @@ from django.apps import apps from django.conf import settings from django.db import DEFAULT_DB_ALIAS, router, transaction +from django.utils.translation import gettext as _ from django.utils.translation import override -from django.utils.translation import ugettext as _ from authentic2.a2_rbac.models import OrganizationalUnit, Role from authentic2.utils.misc import get_fk_model diff --git a/src/authentic2/apps/authenticators/forms.py b/src/authentic2/apps/authenticators/forms.py index 69f47f6c..371ed0b2 100644 --- a/src/authentic2/apps/authenticators/forms.py +++ b/src/authentic2/apps/authenticators/forms.py @@ -16,7 +16,7 @@ from django import forms from django.db.models import Max -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from authentic2.forms.mixins import SlugMixin diff --git a/src/authentic2/apps/authenticators/models.py b/src/authentic2/apps/authenticators/models.py index 8d67d07f..da22fc7d 100644 --- a/src/authentic2/apps/authenticators/models.py +++ b/src/authentic2/apps/authenticators/models.py @@ -23,8 +23,8 @@ from django.db import models from django.shortcuts import render, reverse from django.utils.formats import date_format from django.utils.text import capfirst +from django.utils.translation import gettext_lazy as _ from django.utils.translation import pgettext_lazy -from django.utils.translation import ugettext_lazy as _ from authentic2 import views from authentic2.a2_rbac.models import Role diff --git a/src/authentic2/apps/authenticators/views.py b/src/authentic2/apps/authenticators/views.py index cbf073d5..c4df1d3f 100644 --- a/src/authentic2/apps/authenticators/views.py +++ b/src/authentic2/apps/authenticators/views.py @@ -23,7 +23,7 @@ from django.shortcuts import get_object_or_404 from django.urls import reverse, reverse_lazy from django.utils.functional import cached_property from django.utils.text import slugify -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.generic import CreateView, DeleteView, DetailView, FormView, UpdateView from django.views.generic.list import ListView diff --git a/src/authentic2/apps/journal/forms.py b/src/authentic2/apps/journal/forms.py index ff795bfe..8fd31299 100644 --- a/src/authentic2/apps/journal/forms.py +++ b/src/authentic2/apps/journal/forms.py @@ -20,7 +20,7 @@ from django import forms from django.http import QueryDict from django.utils.formats import date_format from django.utils.functional import cached_property -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from . import models, search_engine diff --git a/src/authentic2/apps/journal/search_engine.py b/src/authentic2/apps/journal/search_engine.py index 050cfd66..4889d290 100644 --- a/src/authentic2/apps/journal/search_engine.py +++ b/src/authentic2/apps/journal/search_engine.py @@ -19,7 +19,7 @@ from functools import reduce from django.contrib.auth import get_user_model from django.db.models import Q -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from . import models diff --git a/src/authentic2/attributes_ng/engine.py b/src/authentic2/attributes_ng/engine.py index d5f35cf0..376f30a8 100644 --- a/src/authentic2/attributes_ng/engine.py +++ b/src/authentic2/attributes_ng/engine.py @@ -16,7 +16,7 @@ import logging -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from .. import app_settings, plugins from ..decorators import to_iter, to_list diff --git a/src/authentic2/attributes_ng/sources/django_user.py b/src/authentic2/attributes_ng/sources/django_user.py index ce4cecc5..8f257c42 100644 --- a/src/authentic2/attributes_ng/sources/django_user.py +++ b/src/authentic2/attributes_ng/sources/django_user.py @@ -15,7 +15,7 @@ # along with this program. If not, see . from django.contrib.auth import get_user_model -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from authentic2.a2_rbac.models import Role diff --git a/src/authentic2/attributes_ng/sources/service_roles.py b/src/authentic2/attributes_ng/sources/service_roles.py index 280ab19b..34a6c35c 100644 --- a/src/authentic2/attributes_ng/sources/service_roles.py +++ b/src/authentic2/attributes_ng/sources/service_roles.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from authentic2.a2_rbac.models import Role diff --git a/src/authentic2/backends/ldap_backend.py b/src/authentic2/backends/ldap_backend.py index b91ad72b..aa8b116a 100644 --- a/src/authentic2/backends/ldap_backend.py +++ b/src/authentic2/backends/ldap_backend.py @@ -39,8 +39,8 @@ from django.core.exceptions import ImproperlyConfigured from django.db.models import Q from django.db.transaction import atomic from django.utils.encoding import force_bytes, force_text +from django.utils.translation import gettext as _ from django.utils.translation import ngettext -from django.utils.translation import ugettext as _ from ldap.controls import DecodeControlTuples, SimplePagedResultsControl, ppolicy from ldap.dn import escape_dn_chars from ldap.filter import filter_format diff --git a/src/authentic2/csv_import.py b/src/authentic2/csv_import.py index 8e20342e..a560809c 100644 --- a/src/authentic2/csv_import.py +++ b/src/authentic2/csv_import.py @@ -27,7 +27,7 @@ from django.core.validators import RegexValidator from django.db import IntegrityError, models from django.db.transaction import atomic from django.utils.encoding import force_bytes, force_text -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from authentic2 import app_settings from authentic2.a2_rbac.models import Role diff --git a/src/authentic2/custom_user/apps.py b/src/authentic2/custom_user/apps.py index ab80d6de..b9402474 100644 --- a/src/authentic2/custom_user/apps.py +++ b/src/authentic2/custom_user/apps.py @@ -34,7 +34,7 @@ class CustomUserConfig(AppConfig): from django.contrib.auth import get_user_model from django.contrib.contenttypes.models import ContentType from django.utils import translation - from django.utils.translation import ugettext_lazy as _ + from django.utils.translation import gettext_lazy as _ from authentic2.attribute_kinds import get_kind from authentic2.models import Attribute, AttributeValue diff --git a/src/authentic2/data_transfer.py b/src/authentic2/data_transfer.py index 3f06514a..e7acc212 100644 --- a/src/authentic2/data_transfer.py +++ b/src/authentic2/data_transfer.py @@ -22,7 +22,7 @@ from django.contrib.contenttypes.models import ContentType from django.core.exceptions import NON_FIELD_ERRORS, ValidationError from django.core.validators import validate_slug from django.utils.text import format_lazy -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from authentic2.a2_rbac.models import OrganizationalUnit, Permission, Role, RoleAttribute, RoleParenting from authentic2.a2_rbac.utils import get_default_ou diff --git a/src/authentic2/disco_service/disco_responder.py b/src/authentic2/disco_service/disco_responder.py index bca9a3d6..67a83641 100644 --- a/src/authentic2/disco_service/disco_responder.py +++ b/src/authentic2/disco_service/disco_responder.py @@ -29,7 +29,7 @@ from xml.dom.minidom import parseString from django.http import HttpResponseRedirect from django.urls import path, reverse from django.utils.http import urlquote -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from authentic2 import settings from authentic2.saml.common import error_page as base_error_page diff --git a/src/authentic2/forms/authentication.py b/src/authentic2/forms/authentication.py index 8be14270..8b3c94da 100644 --- a/src/authentic2/forms/authentication.py +++ b/src/authentic2/forms/authentication.py @@ -23,8 +23,8 @@ from django.contrib.auth import forms as auth_forms from django.forms.widgets import Media from django.utils import html from django.utils.encoding import force_text -from django.utils.translation import ugettext -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext +from django.utils.translation import gettext_lazy as _ from authentic2.forms.fields import PasswordField from authentic2.utils.lazy import lazy_label @@ -70,8 +70,8 @@ class AuthenticationForm(auth_forms.AuthenticationForm): if preferred_ous: choices = self.fields['ou'].choices new_choices = list(choices)[:1] + [ - (ugettext('Preferred organizational units'), [(ou.pk, ou.name) for ou in preferred_ous]), - (ugettext('All organizational units'), list(choices)[1:]), + (gettext('Preferred organizational units'), [(ou.pk, ou.name) for ou in preferred_ous]), + (gettext('All organizational units'), list(choices)[1:]), ] self.fields['ou'].choices = new_choices diff --git a/src/authentic2/forms/fields.py b/src/authentic2/forms/fields.py index d38f1831..1b3071d2 100644 --- a/src/authentic2/forms/fields.py +++ b/src/authentic2/forms/fields.py @@ -23,7 +23,7 @@ from django.core import validators from django.core.files import File from django.forms import CharField, EmailField, FileField, ModelChoiceField, ValidationError from django.forms.fields import FILE_INPUT_CONTRADICTION -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from authentic2 import app_settings from authentic2.a2_rbac.models import Role diff --git a/src/authentic2/forms/mixins.py b/src/authentic2/forms/mixins.py index b49a2766..eb01af46 100644 --- a/src/authentic2/forms/mixins.py +++ b/src/authentic2/forms/mixins.py @@ -19,7 +19,7 @@ from collections import OrderedDict from django import forms from django.utils.text import slugify -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ class LockedFieldFormMixin: diff --git a/src/authentic2/forms/passwords.py b/src/authentic2/forms/passwords.py index 9c04053b..4affd54c 100644 --- a/src/authentic2/forms/passwords.py +++ b/src/authentic2/forms/passwords.py @@ -22,7 +22,7 @@ from django.conf import settings from django.contrib.auth import forms as auth_forms from django.core.exceptions import ValidationError from django.forms import Form -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from authentic2.backends.ldap_backend import LDAPUser from authentic2.journal import journal diff --git a/src/authentic2/forms/registration.py b/src/authentic2/forms/registration.py index a51ad1be..63ff5a3d 100644 --- a/src/authentic2/forms/registration.py +++ b/src/authentic2/forms/registration.py @@ -20,8 +20,8 @@ from django.contrib.auth import get_user_model from django.contrib.auth.models import BaseUserManager, Group from django.core.exceptions import ValidationError from django.core.validators import RegexValidator -from django.utils.translation import ugettext -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext +from django.utils.translation import gettext_lazy as _ from authentic2.a2_rbac.models import OrganizationalUnit from authentic2.forms.fields import CheckPasswordField, NewPasswordField @@ -58,7 +58,7 @@ class RegistrationForm(HoneypotForm): if not email_pattern.endswith('$'): email_pattern += '$' if re.match(email_pattern, email): - raise ValidationError(ugettext('You cannot register with this email.')) + raise ValidationError(gettext('You cannot register with this email.')) return email diff --git a/src/authentic2/forms/widgets.py b/src/authentic2/forms/widgets.py index 62f5a2a3..3486dfd6 100644 --- a/src/authentic2/forms/widgets.py +++ b/src/authentic2/forms/widgets.py @@ -38,7 +38,7 @@ from django.utils.encoding import force_text from django.utils.formats import get_format, get_language from django.utils.safestring import mark_safe from django.utils.text import capfirst -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from gadjo.templatetags.gadjo import xstatic from authentic2 import app_settings diff --git a/src/authentic2/hashers.py b/src/authentic2/hashers.py index 15beb45c..31dd5f4a 100644 --- a/src/authentic2/hashers.py +++ b/src/authentic2/hashers.py @@ -24,7 +24,7 @@ from django.contrib.auth import hashers from django.contrib.auth.hashers import make_password from django.utils.crypto import constant_time_compare from django.utils.encoding import force_bytes, force_text -from django.utils.translation import ugettext_noop as _ +from django.utils.translation import gettext_noop as _ class Drupal7PasswordHasher(hashers.BasePasswordHasher): diff --git a/src/authentic2/idp/saml/backend.py b/src/authentic2/idp/saml/backend.py index b98be7aa..be773fe1 100644 --- a/src/authentic2/idp/saml/backend.py +++ b/src/authentic2/idp/saml/backend.py @@ -23,7 +23,7 @@ from urllib.parse import quote from django.db.models import Q from django.template.loader import render_to_string from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from authentic2.decorators import to_list from authentic2.idp.saml import saml2_endpoints diff --git a/src/authentic2/idp/saml/saml2_endpoints.py b/src/authentic2/idp/saml/saml2_endpoints.py index 3cabecc1..5b39b098 100644 --- a/src/authentic2/idp/saml/saml2_endpoints.py +++ b/src/authentic2/idp/saml/saml2_endpoints.py @@ -52,8 +52,8 @@ from django.shortcuts import redirect, render from django.urls import reverse from django.utils.encoding import force_bytes, force_str, force_text from django.utils.timezone import utc -from django.utils.translation import ugettext as _ -from django.utils.translation import ugettext_noop as N_ +from django.utils.translation import gettext as _ +from django.utils.translation import gettext_noop as N_ from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST diff --git a/src/authentic2/idp/saml/views.py b/src/authentic2/idp/saml/views.py index 81326bc3..2b25b29a 100644 --- a/src/authentic2/idp/saml/views.py +++ b/src/authentic2/idp/saml/views.py @@ -18,7 +18,7 @@ from django.contrib import messages from django.contrib.auth import REDIRECT_FIELD_NAME from django.http import HttpResponseRedirect from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.generic import DeleteView, View from authentic2.saml.models import LibertyFederation diff --git a/src/authentic2/journal_event_types.py b/src/authentic2/journal_event_types.py index 11b4813d..aa7b593d 100644 --- a/src/authentic2/journal_event_types.py +++ b/src/authentic2/journal_event_types.py @@ -15,7 +15,7 @@ # along with this program. If not, see . from django.utils.translation import gettext_lazy as _ -from django.utils.translation import ugettext_noop as N_ +from django.utils.translation import gettext_noop as N_ from authentic2.a2_rbac.models import OrganizationalUnit as OU from authentic2.apps.journal.models import EventTypeDefinition diff --git a/src/authentic2/manager/forms.py b/src/authentic2/manager/forms.py index 1a01e1eb..d96579f4 100644 --- a/src/authentic2/manager/forms.py +++ b/src/authentic2/manager/forms.py @@ -26,8 +26,9 @@ from django.contrib.auth import get_user_model from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError from django.urls import reverse -from django.utils.translation import pgettext, ugettext -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext +from django.utils.translation import gettext_lazy as _ +from django.utils.translation import pgettext from django_select2.forms import HeavySelect2Widget from authentic2.a2_rbac.models import OrganizationalUnit, Permission, Role, RoleAttribute @@ -747,7 +748,7 @@ class UserImportForm(forms.Form): @staticmethod def raise_validation_error(error_message): - message_prefix = ugettext('Invalid import file') + message_prefix = gettext('Invalid import file') raise forms.ValidationError('%s : %s' % (message_prefix, str(error_message))) diff --git a/src/authentic2/manager/journal_views.py b/src/authentic2/manager/journal_views.py index ed87f237..7e309e3a 100644 --- a/src/authentic2/manager/journal_views.py +++ b/src/authentic2/manager/journal_views.py @@ -24,8 +24,8 @@ from django.core.exceptions import ValidationError from django.core.validators import EmailValidator from django.db.models import Q from django.urls import reverse +from django.utils.translation import gettext_lazy as _ from django.utils.translation import pgettext_lazy -from django.utils.translation import ugettext_lazy as _ from django.views.generic.list import ListView from authentic2 import app_settings diff --git a/src/authentic2/manager/ou_views.py b/src/authentic2/manager/ou_views.py index 2e665c98..9abe2f23 100644 --- a/src/authentic2/manager/ou_views.py +++ b/src/authentic2/manager/ou_views.py @@ -21,7 +21,7 @@ from django.core.exceptions import PermissionDenied, ValidationError from django.db import transaction from django.http import HttpResponseRedirect from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.generic import FormView from authentic2 import data_transfer diff --git a/src/authentic2/manager/role_views.py b/src/authentic2/manager/role_views.py index 3ce46980..8f64c373 100644 --- a/src/authentic2/manager/role_views.py +++ b/src/authentic2/manager/role_views.py @@ -29,7 +29,7 @@ from django.http import Http404, JsonResponse from django.shortcuts import get_object_or_404 from django.urls import reverse from django.utils.functional import cached_property -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.generic import DetailView, FormView, TemplateView from django.views.generic.detail import SingleObjectMixin diff --git a/src/authentic2/manager/service_views.py b/src/authentic2/manager/service_views.py index cad708d4..40a534af 100644 --- a/src/authentic2/manager/service_views.py +++ b/src/authentic2/manager/service_views.py @@ -15,7 +15,7 @@ # along with this program. If not, see . from django.contrib import messages -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from authentic2.models import Service diff --git a/src/authentic2/manager/tables.py b/src/authentic2/manager/tables.py index 1a87870a..f8892ef5 100644 --- a/src/authentic2/manager/tables.py +++ b/src/authentic2/manager/tables.py @@ -20,8 +20,8 @@ import django_tables2 as tables from django.contrib.auth import get_user_model from django.utils import html from django.utils.safestring import SafeText -from django.utils.translation import ugettext_lazy as _ -from django.utils.translation import ugettext_noop +from django.utils.translation import gettext_lazy as _ +from django.utils.translation import gettext_noop from django_tables2.utils import A from authentic2.a2_rbac.models import OrganizationalUnit, Permission, Role @@ -235,8 +235,8 @@ class OuUserRolesTable(Table): ' %%}checked{%% endif %%} {%% if not record.has_perm %%}disabled title="{%% trans "%s" %%}"{%% endif' ' %%} {%% if not record.can_manage_members %%}disabled title="{%% trans "%s" %%}"{%% endif %%}/>' % ( - ugettext_noop('You are not authorized to manage this role'), - ugettext_noop('This role is synchronised from LDAP, changing members is not allowed.'), + gettext_noop('You are not authorized to manage this role'), + gettext_noop('This role is synchronised from LDAP, changing members is not allowed.'), ), verbose_name=_('Member'), order_by=('member', 'via', 'name'), diff --git a/src/authentic2/manager/user_import.py b/src/authentic2/manager/user_import.py index 89bb794d..d2ad1e63 100644 --- a/src/authentic2/manager/user_import.py +++ b/src/authentic2/manager/user_import.py @@ -31,7 +31,7 @@ from django.core.files.storage import default_storage from django.db import connection from django.utils.functional import cached_property from django.utils.timezone import utc -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from authentic2.utils.misc import gettid diff --git a/src/authentic2/manager/user_views.py b/src/authentic2/manager/user_views.py index cca22260..ca434bb1 100644 --- a/src/authentic2/manager/user_views.py +++ b/src/authentic2/manager/user_views.py @@ -30,8 +30,9 @@ from django.urls import reverse, reverse_lazy from django.utils import timezone from django.utils.functional import cached_property from django.utils.html import format_html -from django.utils.translation import pgettext_lazy, ugettext -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext +from django.utils.translation import gettext_lazy as _ +from django.utils.translation import pgettext_lazy from django.views.generic import DetailView, FormView, TemplateView, View from django.views.generic.detail import SingleObjectMixin from django.views.generic.edit import BaseFormView @@ -564,9 +565,9 @@ class UserChangePasswordView(ActionMixin, BaseEditView): def get_success_message(self, cleaned_data): if cleaned_data.get('send_mail'): - return ugettext('New password sent to %s') % self.object.email + return gettext('New password sent to %s') % self.object.email else: - return ugettext('New password set') + return gettext('New password set') def form_valid(self, form): response = super().form_valid(form) @@ -591,7 +592,7 @@ class UserChangeEmailView(BaseEditView): def get_success_message(self, cleaned_data): if cleaned_data['new_email'] != self.object.email: - return ugettext('A mail was sent to %s to verify it.') % cleaned_data['new_email'] + return gettext('A mail was sent to %s to verify it.') % cleaned_data['new_email'] return None def form_valid(self, form): diff --git a/src/authentic2/manager/views.py b/src/authentic2/manager/views.py index c2ea4818..7909afe7 100644 --- a/src/authentic2/manager/views.py +++ b/src/authentic2/manager/views.py @@ -31,7 +31,7 @@ from django.urls import reverse, reverse_lazy from django.utils.encoding import force_text from django.utils.functional import cached_property from django.utils.timezone import now -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.generic import CreateView, DeleteView, DetailView, FormView, TemplateView, UpdateView, View from django.views.generic.base import ContextMixin from django.views.generic.detail import SingleObjectMixin diff --git a/src/authentic2/middleware.py b/src/authentic2/middleware.py index 467074fd..f5eeeb22 100644 --- a/src/authentic2/middleware.py +++ b/src/authentic2/middleware.py @@ -29,7 +29,7 @@ from django.conf import settings from django.contrib import messages from django.db.models import Model from django.utils.deprecation import MiddlewareMixin -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from . import app_settings, plugins from .utils import misc as utils_misc diff --git a/src/authentic2/passwords.py b/src/authentic2/passwords.py index 6a2723b6..78d35881 100644 --- a/src/authentic2/passwords.py +++ b/src/authentic2/passwords.py @@ -21,7 +21,7 @@ import string from django.core.exceptions import ValidationError from django.utils.module_loading import import_string -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zxcvbn import zxcvbn from . import app_settings diff --git a/src/authentic2/saml/admin.py b/src/authentic2/saml/admin.py index 712a657a..9964a7ef 100644 --- a/src/authentic2/saml/admin.py +++ b/src/authentic2/saml/admin.py @@ -22,7 +22,7 @@ from django.contrib import admin, messages from django.core.exceptions import ValidationError from django.forms import ModelForm from django.urls import path -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ try: from django.contrib.contenttypes.admin import GenericTabularInline diff --git a/src/authentic2/saml/forms.py b/src/authentic2/saml/forms.py index cfb5f720..70711e68 100644 --- a/src/authentic2/saml/forms.py +++ b/src/authentic2/saml/forms.py @@ -21,7 +21,7 @@ from django import forms from django.conf import settings from django.core.exceptions import ValidationError from django.utils.encoding import force_text -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from authentic2.a2_rbac.models import OrganizationalUnit from authentic2.a2_rbac.utils import get_default_ou diff --git a/src/authentic2/saml/management/commands/mapping.py b/src/authentic2/saml/management/commands/mapping.py index 73340c1f..e51fe73f 100644 --- a/src/authentic2/saml/management/commands/mapping.py +++ b/src/authentic2/saml/management/commands/mapping.py @@ -33,7 +33,7 @@ along with this program. If not, see . ''' -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ def get_def_name_from_oid(oid): diff --git a/src/authentic2/urls.py b/src/authentic2/urls.py index b23d0b51..0baf9546 100644 --- a/src/authentic2/urls.py +++ b/src/authentic2/urls.py @@ -20,7 +20,7 @@ from django.contrib.auth import views as dj_auth_views from django.contrib.auth.decorators import login_required from django.contrib.staticfiles.views import serve from django.urls import include, path, re_path -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.clickjacking import xframe_options_deny from django.views.generic import RedirectView from django.views.generic.base import TemplateView diff --git a/src/authentic2/utils/evaluate.py b/src/authentic2/utils/evaluate.py index 75ad3900..d0833f22 100644 --- a/src/authentic2/utils/evaluate.py +++ b/src/authentic2/utils/evaluate.py @@ -29,7 +29,7 @@ try: except ImportError: from django.utils.lru_cache import lru_cache -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ logger = logging.getLogger(__name__) diff --git a/src/authentic2/utils/template.py b/src/authentic2/utils/template.py index e63adf6c..d1075c0f 100644 --- a/src/authentic2/utils/template.py +++ b/src/authentic2/utils/template.py @@ -17,7 +17,7 @@ from django.core.exceptions import ValidationError from django.template import TemplateSyntaxError, VariableDoesNotExist, engines from django.utils.encoding import force_str -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class TemplateError(Exception): diff --git a/src/authentic2/views.py b/src/authentic2/views.py index 97912160..7e1d29cc 100644 --- a/src/authentic2/views.py +++ b/src/authentic2/views.py @@ -44,7 +44,7 @@ from django.template import loader from django.template.loader import render_to_string from django.urls import reverse, reverse_lazy from django.utils import timezone -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie from django.views.generic import ListView, TemplateView diff --git a/src/authentic2_auth_fc/forms.py b/src/authentic2_auth_fc/forms.py index 1550f299..12accec5 100644 --- a/src/authentic2_auth_fc/forms.py +++ b/src/authentic2_auth_fc/forms.py @@ -15,7 +15,7 @@ # along with this program. If not, see . from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from .models import SCOPE_CHOICES, FcAuthenticator diff --git a/src/authentic2_auth_fc/utils.py b/src/authentic2_auth_fc/utils.py index c2adf9fe..ebd4560b 100644 --- a/src/authentic2_auth_fc/utils.py +++ b/src/authentic2_auth_fc/utils.py @@ -32,7 +32,7 @@ from django.urls import reverse from django.utils.encoding import force_bytes, force_text from django.utils.http import urlencode from django.utils.timezone import now -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry # pylint: disable=import-error diff --git a/src/authentic2_auth_fc/views.py b/src/authentic2_auth_fc/views.py index 84e8d31b..6559dc72 100644 --- a/src/authentic2_auth_fc/views.py +++ b/src/authentic2_auth_fc/views.py @@ -32,7 +32,7 @@ from django.template.loader import render_to_string from django.template.response import TemplateResponse from django.urls import reverse from django.utils.http import urlencode -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.generic import FormView, View from requests_oauthlib import OAuth2Session diff --git a/src/authentic2_auth_oidc/utils.py b/src/authentic2_auth_oidc/utils.py index b6a80f2e..809f5260 100644 --- a/src/authentic2_auth_oidc/utils.py +++ b/src/authentic2_auth_oidc/utils.py @@ -20,7 +20,7 @@ import urllib.parse import requests from django.shortcuts import get_object_or_404 from django.utils.timezone import utc -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from jwcrypto.common import JWException, base64url_encode, json_decode from jwcrypto.jwk import JWK from jwcrypto.jwt import JWT diff --git a/src/authentic2_auth_oidc/views.py b/src/authentic2_auth_oidc/views.py index c4ab80ed..8044fe44 100644 --- a/src/authentic2_auth_oidc/views.py +++ b/src/authentic2_auth_oidc/views.py @@ -26,7 +26,7 @@ from django.contrib.auth import REDIRECT_FIELD_NAME from django.http import HttpResponseBadRequest from django.urls import reverse from django.utils.translation import get_language -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.generic.base import View from authentic2.utils import crypto diff --git a/src/authentic2_auth_saml/adapters.py b/src/authentic2_auth_saml/adapters.py index b729861d..7c048c74 100644 --- a/src/authentic2_auth_saml/adapters.py +++ b/src/authentic2_auth_saml/adapters.py @@ -19,7 +19,7 @@ import logging from django.contrib import messages from django.db.transaction import atomic -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from mellon.adapters import DefaultAdapter, UserCreationError from authentic2.a2_rbac.utils import get_default_ou diff --git a/src/authentic2_auth_saml/migrations/0003_auto_20220726_1713.py b/src/authentic2_auth_saml/migrations/0003_auto_20220726_1713.py index 569ff63b..f05c79b7 100644 --- a/src/authentic2_auth_saml/migrations/0003_auto_20220726_1713.py +++ b/src/authentic2_auth_saml/migrations/0003_auto_20220726_1713.py @@ -3,7 +3,7 @@ from django.conf import settings from django.db import migrations from django.utils import translation -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ def set_default_button_label(apps, schema_editor): diff --git a/src/authentic2_idp_cas/admin.py b/src/authentic2_idp_cas/admin.py index 19775c5f..aabeb6c4 100644 --- a/src/authentic2_idp_cas/admin.py +++ b/src/authentic2_idp_cas/admin.py @@ -16,7 +16,7 @@ from django import forms from django.contrib import admin -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from authentic2.admin import CleanupAdminMixin from authentic2.attributes_ng.engine import get_attribute_names diff --git a/src/authentic2_idp_oidc/manager/views.py b/src/authentic2_idp_oidc/manager/views.py index a491b211..3e56f8de 100644 --- a/src/authentic2_idp_oidc/manager/views.py +++ b/src/authentic2_idp_oidc/manager/views.py @@ -15,7 +15,7 @@ # along with this program. If not, see . from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from authentic2.manager import views from authentic2_idp_oidc import app_settings diff --git a/src/authentic2_idp_oidc/views.py b/src/authentic2_idp_oidc/views.py index ef410d6e..f63800cc 100644 --- a/src/authentic2_idp_oidc/views.py +++ b/src/authentic2_idp_oidc/views.py @@ -31,7 +31,7 @@ from django.urls import reverse from django.utils.encoding import force_text from django.utils.http import urlencode from django.utils.timezone import now, utc -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.csrf import csrf_exempt from ratelimit.utils import is_ratelimited diff --git a/src/django_rbac/models.py b/src/django_rbac/models.py index 76d96811..b181b8db 100644 --- a/src/django_rbac/models.py +++ b/src/django_rbac/models.py @@ -16,8 +16,8 @@ except ImportError: from django.db import models +from django.utils.translation import gettext_lazy as _ from django.utils.translation import pgettext_lazy -from django.utils.translation import ugettext_lazy as _ from . import backends, managers diff --git a/tests/test_all.py b/tests/test_all.py index 0fe41bd6..c2665d8f 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -29,7 +29,7 @@ from django.test.client import Client from django.test.utils import override_settings from django.urls import reverse from django.utils.encoding import force_text -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from rest_framework import status, test from authentic2 import attribute_kinds, models -- 2.37.2