From 8e5f14b0217ae5e7ae5c14828ba8860f89fcaab4 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Wed, 3 Oct 2018 22:45:47 +0200 Subject: [PATCH] misc: move account related texts into to templates (#21017) --- src/authentic2/registration_backend/views.py | 9 +++++---- src/authentic2/templates/authentic2/accounts.html | 4 ++-- src/authentic2/templates/authentic2/accounts_delete.html | 4 ++-- src/authentic2/templates/authentic2/accounts_edit.html | 4 ++-- .../templates/registration/account_deletion_message.html | 1 + .../registration/registration_success_message.html | 1 + src/authentic2/views.py | 2 -- 7 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 src/authentic2/templates/registration/account_deletion_message.html create mode 100644 src/authentic2/templates/registration/registration_success_message.html diff --git a/src/authentic2/registration_backend/views.py b/src/authentic2/registration_backend/views.py index 3338dbc2..d57080a2 100644 --- a/src/authentic2/registration_backend/views.py +++ b/src/authentic2/registration_backend/views.py @@ -15,6 +15,7 @@ from django.contrib.auth import get_user_model from django.forms import CharField, Form from django.core.urlresolvers import reverse_lazy from django.http import Http404, HttpResponseBadRequest +from django.template import loader from authentic2.utils import (import_module_or_class, redirect, make_url, get_fields_and_labels, simulate_authentication) @@ -340,7 +341,8 @@ class RegistrationCompletionView(CreateView): token=request.token, service=self.service) simulate_authentication(request, user, method=self.authentication_method, service_slug=self.service) - messages.info(self.request, _('You have just created an account.')) + message_template = loader.get_template('registration/registration_success_message.html') + messages.info(self.request, message_template.render(request=request)) self.send_registration_success_email(user) return redirect(request, self.get_success_url()) @@ -365,7 +367,6 @@ class RegistrationCompletionView(CreateView): class DeleteView(FormView): template_name = 'authentic2/accounts_delete.html' success_url = reverse_lazy('auth_logout') - title = _('Delete account') def dispatch(self, request, *args, **kwargs): if not app_settings.A2_REGISTRATION_CAN_DELETE_ACCOUNT: @@ -395,8 +396,8 @@ class DeleteView(FormView): self.request.user.save(update_fields=['email', 'email_verified']) logger.info(u'deletion of account %s requested', self.request.user) hooks.call_hooks('event', name='delete-account', user=self.request.user) - messages.info(self.request, - _('Your account has been scheduled for deletion. You cannot use it anymore.')) + message_template = loader.get_template('registration/account_deletion_message.html') + messages.info(self.request, message_template.render(request=self.request)) return super(DeleteView, self).form_valid(form) registration_completion = valid_token(RegistrationCompletionView.as_view()) diff --git a/src/authentic2/templates/authentic2/accounts.html b/src/authentic2/templates/authentic2/accounts.html index 4e9f979f..2f9abfd5 100644 --- a/src/authentic2/templates/authentic2/accounts.html +++ b/src/authentic2/templates/authentic2/accounts.html @@ -2,12 +2,12 @@ {% load i18n %} {% block page-title %} - {{ block.super }} - {{ view.title }} + {{ block.super }} - {% trans "Your account" %} {% endblock %} {% block breadcrumb %} {{ block.super }} - {{ view.title }} + {% trans "Your account" %} {% endblock %} {% block content %} diff --git a/src/authentic2/templates/authentic2/accounts_delete.html b/src/authentic2/templates/authentic2/accounts_delete.html index 9767ae1d..691b9fb0 100644 --- a/src/authentic2/templates/authentic2/accounts_delete.html +++ b/src/authentic2/templates/authentic2/accounts_delete.html @@ -2,13 +2,13 @@ {% load i18n %} {% block page-title %} - {{ block.super }} - {{ view.title }} + {{ block.super }} - {% trans "Delete account" %} {% endblock %} {% block breadcrumb %} {{ block.super }} {% trans "Your account" %} - {{ view.title }} + {% trans "Delete account" %} {% endblock %} diff --git a/src/authentic2/templates/authentic2/accounts_edit.html b/src/authentic2/templates/authentic2/accounts_edit.html index c7587b14..071cf731 100644 --- a/src/authentic2/templates/authentic2/accounts_edit.html +++ b/src/authentic2/templates/authentic2/accounts_edit.html @@ -2,13 +2,13 @@ {% load i18n %} {% block page-title %} - {{ block.super }} - {{ view.title }} + {{ block.super }} - {% trans "Edit account data" %} {% endblock %} {% block breadcrumb %} {{ block.super }} {% trans "Your account" %} - {{ view.title }} + {% trans "Edit account data" %} {% endblock %} {% block content %} diff --git a/src/authentic2/templates/registration/account_deletion_message.html b/src/authentic2/templates/registration/account_deletion_message.html new file mode 100644 index 00000000..902f5690 --- /dev/null +++ b/src/authentic2/templates/registration/account_deletion_message.html @@ -0,0 +1 @@ +{% load i18n %}{% trans "Your account has been scheduled for deletion. You cannot use it anymore." %} diff --git a/src/authentic2/templates/registration/registration_success_message.html b/src/authentic2/templates/registration/registration_success_message.html new file mode 100644 index 00000000..dedd2414 --- /dev/null +++ b/src/authentic2/templates/registration/registration_success_message.html @@ -0,0 +1 @@ +{% load i18n %}{% trans "You have just created an account." %} diff --git a/src/authentic2/views.py b/src/authentic2/views.py index c9d8d9a7..d21be7a1 100644 --- a/src/authentic2/views.py +++ b/src/authentic2/views.py @@ -65,7 +65,6 @@ class EditProfile(cbv.HookMixin, cbv.TemplateNamesMixin, UpdateView): model = compat.get_user_model() template_names = ['profiles/edit_profile.html', 'authentic2/accounts_edit.html'] - title = _('Edit account data') def get_template_names(self): template_names = [] @@ -394,7 +393,6 @@ homepage = Homepage.as_view() class ProfileView(cbv.TemplateNamesMixin, TemplateView): template_names = ['idp/account_management.html', 'authentic2/accounts.html'] - title = _('Your account') def dispatch(self, request, *args, **kwargs): if app_settings.A2_ACCOUNTS_URL: -- 2.19.0