From b25a852effbacdb249a840ce1cbf529c80e10f58 Mon Sep 17 00:00:00 2001
From: Serghei Mihai <smihai@entrouvert.com>
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 f56b18f2..3cb0e427 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 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 }}
-  <a href="">{{ view.title }}</a>
+  <a href="">{% trans "Your account" %}</a>
 {% 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 }}
   <a href="{% url "account_management" %}">{% trans "Your account" %}</a>
-  <a href="#">{{ view.title }}</a>
+  <a href="#">{% trans "Delete account" %}</a>
 {% 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 }}
   <a href="..">{% trans "Your account" %}</a>
-  <a href="">{{ view.title }}</a>
+  <a href="">{% trans "Edit account data" %}</a>
 {% 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 96032509..d7e68fb4 100644
--- a/src/authentic2/views.py
+++ b/src/authentic2/views.py
@@ -64,7 +64,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.20.1

