Projet

Général

Profil

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

Serghei Mihai (congés, retour 15/05), 23 août 2022 11:29

Télécharger (5,02 ko)

Voir les différences:

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

 .../templates/authentic2/login_password_form.html          | 3 +++
 .../authentic2/login_password_registration_form.html       | 6 ++++++
 .../templates/registration/registration_form.html          | 3 ---
 src/authentic2_auth_fc/models.py                           | 2 +-
 .../templates/authentic2_auth_fc/login.html                | 7 ++++++-
 .../templates/authentic2_auth_fc/registration.html         | 7 +++++++
 src/authentic2_auth_fc/views.py                            | 7 ++++++-
 7 files changed, 29 insertions(+), 6 deletions(-)
 create mode 100644 src/authentic2_auth_fc/templates/authentic2_auth_fc/registration.html
src/authentic2/templates/authentic2/login_password_form.html
1 1
{% load i18n static gadjo %}
2 2

  
3
{% block login-block-title %}
4
{% endblock %}
5

  
3 6
{% block login %}
4 7

  
5 8
{% block form %}
src/authentic2/templates/authentic2/login_password_registration_form.html
1 1
{% load i18n gadjo %}
2 2

  
3
{% block registration-block-title %}
4
<h2>{% trans "Registration" %}</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/models.py
130 130
        return views.profile(request, *args, **kwargs)
131 131

  
132 132
    def registration(self, request, *args, **kwargs):
133
        return self.login(request, *args, **kwargs)
133
        return views.registration(request, *args, **kwargs)
134 134

  
135 135

  
136 136
class FcAccount(models.Model):
src/authentic2_auth_fc/templates/authentic2_auth_fc/login.html
1 1
{% load static %}
2 2
{% load i18n %}
3 3

  
4
{% block login %}
4
{% block title %}
5
{% block login-block-title %}
6
{% endblock %}
7
{% endblock %}
8

  
9
{% block content %}
5 10
<div id="fc-button-wrapper">
6 11
  <div id="fc-button">
7 12
    <a href="{{ login_url }}"
src/authentic2_auth_fc/templates/authentic2_auth_fc/registration.html
1
{% extends "authentic2_auth_fc/login.html" %}
2

  
3
{% block title %}
4
{% block registration-block-title %}
5
<h2>FranceConnect</h2>
6
{% endblock %}
7
{% endblock %}
src/authentic2_auth_fc/views.py
76 76
    )
77 77
    context['login_url'] = utils_misc.make_url('fc-login-or-link', keep_params=True, request=request)
78 78
    context['block-extra-css-class'] = 'fc-login'
79
    template = 'authentic2_auth_fc/login.html'
79
    template = kwargs.get('template', 'authentic2_auth_fc/login.html')
80 80
    return TemplateResponse(request, template, context)
81 81

  
82 82

  
83
def registration(request, *args, **kwargs):
84
    kwargs['template'] = 'authentic2_auth_fc/registration.html'
85
    return login(request, *args, **kwargs)
86

  
87

  
83 88
def profile(request, *args, **kwargs):
84 89
    # We prevent unlinking if the user has no usable password and can't change it
85 90
    # because we assume that the password is the unique other mean of authentication
86
-