Projet

Général

Profil

0001-misc-move-account-related-texts-into-to-templates-21.patch

Benjamin Dauvergne, 04 juillet 2019 11:42

Télécharger (6,24 ko)

Voir les différences:

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 ++--
 .../registration/account_deletion_message.html        |  1 +
 .../registration/registration_success_message.html    |  1 +
 src/authentic2/views.py                               | 11 +++++------
 6 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
src/authentic2/templates/authentic2/accounts.html
2 2
{% load i18n %}
3 3

  
4 4
{% block page-title %}
5
  {{ block.super }} - {{ view.title }}
5
  {{ block.super }} - {% trans "Your account" %}
6 6
{% endblock %}
7 7

  
8 8
{% block breadcrumb %}
9 9
  {{ block.super }}
10
  <a href="">{{ view.title }}</a>
10
  <a href="">{% trans "Your account" %}</a>
11 11
{% endblock %}
12 12

  
13 13
{% block content %}
src/authentic2/templates/authentic2/accounts_delete.html
2 2
{% load i18n %}
3 3

  
4 4
{% block page-title %}
5
  {{ block.super }} - {{ view.title }}
5
  {{ block.super }} - {% trans "Delete account" %}
6 6
{% endblock %}
7 7

  
8 8
{% block breadcrumb %}
9 9
  {{ block.super }}
10 10
  <a href="{% url "account_management" %}">{% trans "Your account" %}</a>
11
  <a href="#">{{ view.title }}</a>
11
  <a href="#">{% trans "Delete account" %}</a>
12 12
{% endblock %}
13 13

  
14 14

  
src/authentic2/templates/authentic2/accounts_edit.html
2 2
{% load i18n %}
3 3

  
4 4
{% block page-title %}
5
  {{ block.super }} - {{ view.title }}
5
  {{ block.super }} - {% trans "Edit account data" %}
6 6
{% endblock %}
7 7

  
8 8
{% block breadcrumb %}
9 9
  {{ block.super }}
10 10
  <a href="..">{% trans "Your account" %}</a>
11
  <a href="">{{ view.title }}</a>
11
  <a href="">{% trans "Edit account data" %}</a>
12 12
{% endblock %}
13 13

  
14 14
{% block content %}
src/authentic2/templates/registration/account_deletion_message.html
1
{% load i18n %}{% trans "Your account has been scheduled for deletion. You cannot use it anymore." %}
src/authentic2/templates/registration/registration_success_message.html
1
{% load i18n %}{% trans "You have just created an account." %}
src/authentic2/views.py
50 50
from django.forms import CharField, Form
51 51
from django.core.urlresolvers import reverse_lazy
52 52
from django.http import HttpResponseBadRequest
53
from django.template import loader
53 54

  
54 55
from . import (utils, app_settings, compat, decorators, constants,
55 56
               models, cbv, hooks, validators)
......
79 80
    model = User
80 81
    template_names = ['profiles/edit_profile.html',
81 82
                      'authentic2/accounts_edit.html']
82
    title = _('Edit account data')
83 83

  
84 84
    def get_template_names(self):
85 85
        template_names = []
......
402 402

  
403 403
class ProfileView(cbv.TemplateNamesMixin, TemplateView):
404 404
    template_names = ['idp/account_management.html', 'authentic2/accounts.html']
405
    title = _('Your account')
406 405

  
407 406
    def dispatch(self, request, *args, **kwargs):
408 407
        if app_settings.A2_ACCOUNTS_URL:
......
1057 1056
            request, user,
1058 1057
            method=self.authentication_method,
1059 1058
            service_slug=self.service)
1060
        messages.info(self.request, _('You have just created an account.'))
1059
        message_template = loader.get_template('registration/registration_success_message.html')
1060
        messages.info(self.request, message_template.render(request=request))
1061 1061
        self.send_registration_success_email(user)
1062 1062
        return utils.redirect(request, self.get_success_url())
1063 1063

  
......
1082 1082
class DeleteView(FormView):
1083 1083
    template_name = 'authentic2/accounts_delete.html'
1084 1084
    success_url = reverse_lazy('auth_logout')
1085
    title = _('Delete account')
1086 1085

  
1087 1086
    def dispatch(self, request, *args, **kwargs):
1088 1087
        if not app_settings.A2_REGISTRATION_CAN_DELETE_ACCOUNT:
......
1113 1112
        self.request.user.save(update_fields=['email', 'email_verified'])
1114 1113
        logger.info(u'deletion of account %s requested', self.request.user)
1115 1114
        hooks.call_hooks('event', name='delete-account', user=self.request.user)
1116
        messages.info(self.request,
1117
                      _('Your account has been scheduled for deletion. You cannot use it anymore.'))
1115
        message_template = loader.get_template('registration/account_deletion_message.html')
1116
        messages.info(self.request, message_template.render(request=self.request))
1118 1117
        return super(DeleteView, self).form_valid(form)
1119 1118

  
1120 1119
registration_completion = valid_token(RegistrationCompletionView.as_view())
1121
-