Projet

Général

Profil

0001-misc-render-authenticators-names-in-their-own-templa.patch

Serghei Mihai, 31 mai 2022 12:07

Télécharger (4,53 ko)

Voir les différences:

Subject: [PATCH] misc: render authenticators names in their own templates
 (#53264)

 src/authentic2/apps/authenticators/models.py                | 1 +
 .../authentic2/login_password_registration_form.html        | 6 ++++++
 .../templates/registration/registration_form.html           | 3 ---
 src/authentic2_auth_fc/authenticators.py                    | 4 +++-
 .../templates/authentic2_auth_fc/login.html                 | 3 +++
 .../templates/authentic2_auth_fc/registration.html          | 5 +++++
 6 files changed, 18 insertions(+), 4 deletions(-)
 create mode 100644 src/authentic2_auth_fc/templates/authentic2_auth_fc/registration.html
src/authentic2/apps/authenticators/models.py
143 143

  
144 144
    def registration(self, request, *args, **kwargs):
145 145
        context = kwargs.get('context', {})
146
        context['name'] = str(self)
146 147
        return render(request, 'authentic2/login_password_registration_form.html', context)
src/authentic2/templates/authentic2/login_password_registration_form.html
1 1
{% load i18n gadjo %}
2 2

  
3
{% block title %}
4
<h2>{{ name }}</h2>
5
{% endblock %}
6

  
3 7
{% block registration %}
8
<p>
4 9
<form enctype="multipart/form-data" method="post" class="pk-mark-optional-fields">
5 10
  {% csrf_token %}
6 11
  {{ form|with_template }}
......
8 13
  <button class="submit-button">{% trans 'Submit' %}</button>
9 14
  </div>
10 15
</form>
16
</p>
11 17
{% endblock %}
src/authentic2/templates/registration/registration_form.html
13 13

  
14 14
{% for id, block in frontends.items %}
15 15
  <div class="registration_frontend">
16
    <h2>{{ block.name }}</h2>
17
    <p>
18 16
      {{ block.content|safe }}
19
    </p>
20 17
  </div>
21 18
{% endfor %}
22 19

  
src/authentic2_auth_fc/authenticators.py
57 57
        )
58 58
        context['login_url'] = utils_misc.make_url('fc-login-or-link', keep_params=True, request=request)
59 59
        context['block-extra-css-class'] = 'fc-login'
60
        template = 'authentic2_auth_fc/login.html'
60
        context['name'] = self.name
61
        template = kwargs.get('template', 'authentic2_auth_fc/login.html')
61 62
        return TemplateResponse(request, template, context)
62 63

  
63 64
    def profile(self, request, *args, **kwargs):
......
83 84
        return render_to_string('authentic2_auth_fc/linking.html', context, request=request)
84 85

  
85 86
    def registration(self, request, *args, **kwargs):
87
        kwargs['template'] = 'authentic2_auth_fc/registration.html'
86 88
        return self.login(request, *args, **kwargs)
src/authentic2_auth_fc/templates/authentic2_auth_fc/login.html
1 1
{% load static %}
2 2
{% load i18n %}
3 3

  
4
{% block title %}
5
{% endblock %}
6

  
4 7
{% block login %}
5 8
<link rel="stylesheet" type="text/css" href="{% static 'authentic2_auth_fc/css/fc.css' %}">
6 9
<div id="fc-button-wrapper">
src/authentic2_auth_fc/templates/authentic2_auth_fc/registration.html
1
{% extends "authentic2_auth_fc/login.html" %}
2

  
3
{% block title %}
4
<h2>{{ name }}</h2>
5
{% endblock %}
0
-