Projet

Général

Profil

0001-registration-show-only-email-address-in-post-registr.patch

Thomas Noël, 11 décembre 2019 14:01

Télécharger (3,01 ko)

Voir les différences:

Subject: [PATCH] registration: show only email address in post-registratio
 message (#37923)

 .../templates/registration/registration_complete.html         | 2 +-
 src/authentic2/views.py                                       | 2 ++
 tests/test_registration.py                                    | 4 +++-
 3 files changed, 6 insertions(+), 2 deletions(-)
src/authentic2/templates/registration/registration_complete.html
27 27
    </p>
28 28
    <p>
29 29
    {% blocktrans with from_email=from_email %}
30
    If you still have not received the instructions, add {{from_email}}
30
    If you still have not received the instructions, add "{{from_email_address}}"
31 31
    to your address book or authorized sender list, and then repeat the
32 32
    registration process.
33 33
    {% endblocktrans %}
src/authentic2/views.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import collections
18
from email.utils import parseaddr
18 19
import logging
19 20
import random
20 21
import re
......
1153 1154
    def get_context_data(self, **kwargs):
1154 1155
        kwargs['next_url'] = utils.select_next_url(self.request, settings.LOGIN_REDIRECT_URL)
1155 1156
        kwargs['from_email'] = settings.DEFAULT_FROM_EMAIL
1157
        kwargs['from_email_address'] = parseaddr(settings.DEFAULT_FROM_EMAIL)[1]
1156 1158
        return super(RegistrationCompleteView, self).get_context_data(
1157 1159
            account_activation_days=settings.ACCOUNT_ACTIVATION_DAYS,
1158 1160
            **kwargs)
tests/test_registration.py
32 32

  
33 33
    settings.LANGUAGE_CODE = 'en-us'
34 34
    settings.A2_VALIDATE_EMAIL_DOMAIN = can_resolve_dns()
35
    settings.DEFAULT_FROM_EMAIL = 'show only addr <noreply@example.net>'
35 36

  
36 37
    # disable existing attributes
37 38
    models.Attribute.objects.update(disabled=True)
......
55 56
    assert 'Follow the instructions' in response.text
56 57
    assert 'testbot@entrouvert.com' in response.text
57 58
    assert 'considered as spam' in response.text
58
    assert settings.DEFAULT_FROM_EMAIL in response.text
59
    assert '"noreply@example.net"' in response.text
60
    assert 'show only addr' not in response.text
59 61
    assert len(mailoutbox) == 1
60 62

  
61 63
    link = get_link_from_mail(mailoutbox[0])
62
-