From 7f997366674905392a4456e3275ad94c36185c3c Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 4 Jul 2019 09:33:00 +0200 Subject: [PATCH] misc: move account related texts into to templates (#21017) --- src/authentic2/templates/authentic2/accounts.html | 4 ++-- .../templates/authentic2/accounts_delete.html | 4 ++-- .../templates/authentic2/accounts_edit.html | 4 ++-- src/authentic2/views.py | 11 +++++------ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/authentic2/templates/authentic2/accounts.html b/src/authentic2/templates/authentic2/accounts.html index dff3645f..100c6d0e 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 a5bbfba6..29158cb3 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 97a03324..f01efd28 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/views.py b/src/authentic2/views.py index 644f6fb6..5b50b53e 100644 --- a/src/authentic2/views.py +++ b/src/authentic2/views.py @@ -50,6 +50,7 @@ from django.views.generic.edit import CreateView from django.forms import CharField, Form from django.core.urlresolvers import reverse_lazy from django.http import HttpResponseBadRequest +from django.template import loader from . import (utils, app_settings, compat, decorators, constants, models, cbv, hooks, validators) @@ -79,7 +80,6 @@ class EditProfile(cbv.HookMixin, cbv.TemplateNamesMixin, UpdateView): model = User template_names = ['profiles/edit_profile.html', 'authentic2/accounts_edit.html'] - title = _('Edit account data') def get_template_names(self): template_names = [] @@ -402,7 +402,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: @@ -1057,7 +1056,8 @@ class RegistrationCompletionView(CreateView): 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 utils.redirect(request, self.get_success_url()) @@ -1082,7 +1082,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: @@ -1113,8 +1112,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()) -- 2.20.1