Projet

Général

Profil

0001-templates-use-with_template-template-tag-to-render-f.patch

Serghei Mihai, 11 août 2020 17:37

Télécharger (10,5 ko)

Voir les différences:

Subject: [PATCH] templates: use with_template template tag to render forms
 (#40159)

 src/authentic2/templates/authentic2/change_email.html       | 6 +++---
 .../templates/authentic2/login_password_form.html           | 6 +++---
 .../authentic2/login_password_registration_form.html        | 6 +++---
 .../templates/registration/password_change_form.html        | 6 +++---
 .../templates/registration/password_reset_confirm.html      | 6 +++---
 .../templates/registration/password_reset_form.html         | 6 +++---
 .../registration/registration_completion_form.html          | 6 +++---
 .../templates/authentic2_auth_fc/unlink.html                | 4 ++--
 tests/test_ldap.py                                          | 4 ++--
 tests/test_login.py                                         | 5 ++---
 tests/test_registration.py                                  | 3 ++-
 11 files changed, 29 insertions(+), 29 deletions(-)
src/authentic2/templates/authentic2/change_email.html
1 1
{% extends "authentic2/base-page.html" %}
2
{% load i18n %}
2
{% load i18n gadjo %}
3 3

  
4 4
{% block page-title %}
5 5
  {{ block.super }} - {{ view.title }}
......
14 14
{% block content %}
15 15
  <p>{% blocktrans with email=user.email %}Your current email is {{ email }}.
16 16
  An email will be sent to validate the new one.{% endblocktrans %}</p>
17
  <form method="post">
17
  <form method="post" class="pk-mark-optional-fields">
18 18
    {% csrf_token %}
19
    {{ form.as_p }}
19
    {{ form|with_template }}
20 20
    <button class="submit-button">{% trans "Validate" %}</button>
21 21
    <button class="cancel-button" name="cancel" formnovalidate>{% trans "Cancel" %}</button>
22 22
  </form>
src/authentic2/templates/authentic2/login_password_form.html
1
{% load i18n staticfiles %}
1
{% load i18n staticfiles gadjo %}
2 2

  
3 3
{% block login %}
4 4

  
5 5
{% block form %}
6 6
<div>
7
<form method="post">
7
<form method="post" class="pk-mark-optional-fields">
8 8
{% csrf_token %}
9
{{ form.as_p }}
9
{{ form|with_template }}
10 10
{% block buttons %}
11 11
<button class="submit-button" name="{{ submit_name }}">{% trans "Log in" %}</button>
12 12
{% if cancel %}
src/authentic2/templates/authentic2/login_password_registration_form.html
1
{% load i18n %}
1
{% load i18n gadjo %}
2 2

  
3 3
{% block registration %}
4
<form enctype="multipart/form-data" method="post">
4
<form enctype="multipart/form-data" method="post" class="pk-mark-optional-fields">
5 5
  {% csrf_token %}
6
  {{ form.as_p }}
6
  {{ form|with_template }}
7 7
  <button class="submit-button">{% trans 'Submit' %}</button>
8 8
</form>
9 9
{% endblock %}
src/authentic2/templates/registration/password_change_form.html
1 1
{% extends "authentic2/base-page.html" %}
2
{% load i18n %}
2
{% load i18n gadjo %}
3 3

  
4 4
{% block page-title %}
5 5
  {{ block.super }} - {{ view.title }}
......
12 12
{% endblock %}
13 13

  
14 14
{% block content %}
15
  <form method="post" action=".">
15
  <form method="post" action="." class="pk-mark-optional-fields">
16 16
    {% if user.has_usable_password %}
17 17
    <p>{% blocktrans %}To change your password you must provide your current password, then provide
18 18
    the new password and confirm it.
......
21 21
    <p>{% blocktrans %}You are going to define your account password.{% endblocktrans %}</p>
22 22
    {% endif %}
23 23
    {% csrf_token %}
24
    {{ form.as_p }}
24
    {{ form|with_template }}
25 25
    <button class="submit-button">{% trans 'Submit' %}</button>
26 26
    <button class="cancel-button" name="cancel" formnovalidate>{% trans "Cancel" %}</button>
27 27
  </form>
src/authentic2/templates/registration/password_reset_confirm.html
1 1
{% extends "authentic2/base-page.html" %}
2
{% load i18n %}
2
{% load i18n gadjo %}
3 3

  
4 4
{% block title %}
5 5
{{ view.title }}
......
9 9

  
10 10
{% if validlink %}
11 11

  
12
<form method="post">
12
<form method="post" class="pk-mark-optional-fields">
13 13
  {% csrf_token %}
14
  {{ form.as_p }}
14
  {{ form|with_template }}
15 15

  
16 16
  <button class="submit-button">{% trans 'Submit' %}</button>
17 17
</form>
src/authentic2/templates/registration/password_reset_form.html
1 1
{% extends "authentic2/base-page.html" %}
2
{% load i18n %}
2
{% load i18n gadjo %}
3 3

  
4 4
{% block title %}
5 5
{% trans "Resetting password" %}
......
9 9

  
10 10
<h2>{% trans "Resetting password" %}</h2>
11 11

  
12
<form method="post">
12
<form method="post" class="pk-mark-optional-fields">
13 13
  {% csrf_token %}
14
  {{ form.as_p }}
14
  {{ form|with_template }}
15 15

  
16 16
  <button class="submit-button">{% trans 'Submit' %}</button>
17 17
</form>
src/authentic2/templates/registration/registration_completion_form.html
1 1
{% extends "authentic2/base-page.html" %}
2
{% load i18n %}
2
{% load i18n gadjo %}
3 3

  
4 4
{% block title %}
5 5
    {% trans "Registration" %}
......
10 10
      <h2>{% trans "Registration" %}</h2>
11 11
      <p>{% trans "Please fill the form to complete your registration" %}</p>
12 12
      {% endblock %}
13
      <form method="post" class="a2-registration-completion-form">
13
      <form method="post" class="a2-registration-completion-form pk-mark-optional-fields">
14 14
        {% block registration-completion-form-top %}{% endblock %}
15 15
        {% csrf_token %}
16
        {{ form.as_p }}
16
        {{ form|with_template }}
17 17
        <button class="submit-button">{% trans 'Submit' %}</button>
18 18
        {% block registration-completion-form-bottom %}{% endblock %}
19 19
        {% csrf_token %}
src/authentic2_auth_fc/templates/authentic2_auth_fc/unlink.html
1 1
{% extends "authentic2_auth_fc/base.html"%}
2 2
{% load staticfiles %}
3
{% load i18n %}
3
{% load i18n gadjo %}
4 4

  
5 5
{% block content %}
6 6
    <p>
......
26 26
    {% endif %}
27 27
    <form method="post">
28 28
        {% csrf_token %}
29
        {{ form.as_p }}
29
        {{ form|with_template }}
30 30
        <button class="submit-button" name="unlink">{% trans "Unlink" %}</button>
31 31
        <button class="cancel-button" name="cancel" formnovalidate>{% trans "Cancel" %}</button>
32 32
    </form>
tests/test_ldap.py
847 847
    response.form.set('password', PASS)
848 848
    response.form.set('ou', str(get_default_ou().pk))
849 849
    response = response.form.submit(name='login-password-submit')
850
    assert response.pyquery('.errorlist.nonfield')
850
    assert response.pyquery('.errornotice')
851 851
    assert '_auth_user_id' not in app.session
852 852

  
853 853
    # Check login to the proper ou works
......
875 875
    response.form.set('password', PASS)
876 876
    response.form.set('ou', str(ou1.pk))
877 877
    response = response.form.submit(name='login-password-submit')
878
    assert response.pyquery('.errorlist.nonfield')
878
    assert response.pyquery('.errornotice')
879 879
    assert '_auth_user_id' not in app.session
880 880

  
881 881
    # Check login to the proper ou works
tests/test_login.py
174 174
    response.form.set('username', simple_user.username)
175 175
    response.form.set('password', simple_user.username)
176 176
    response = response.form.submit(name='login-password-submit')
177
    assert response.pyquery('.errorlist')
177
    assert response.pyquery('.widget-with-error')
178 178
    # Check login to the wrong ou do not work
179 179
    response.form.set('password', simple_user.username)
180 180
    response.form.set('ou', str(ou1.pk))
181 181
    response = response.form.submit(name='login-password-submit')
182
    assert not response.pyquery('.errorlist:not(.nonfield)')
183
    assert response.pyquery('.errorlist.nonfield')
182
    assert response.pyquery('.errornotice')
184 183
    assert '_auth_user_id' not in app.session
185 184
    # Check login to the proper ou works
186 185
    response.form.set('password', simple_user.username)
tests/test_registration.py
202 202
        assert response.pyquery('[for=id_%s]' % key)
203 203
        assert response.pyquery('[for=id_%s]' % key).attr('class') == 'form-field-required'
204 204

  
205
    assert response.pyquery('#id_username').next('.helptext').text() == 'Bien remplir'
205
    print(response.text)
206
    assert response.pyquery('#id_username').next('.hint').text() == 'Bien remplir'
206 207
    assert not response.pyquery('.errorlist')
207 208

  
208 209
    # check username is validated using regexp
209
-