Projet

Général

Profil

0001-agendas-include-event-description-in-reminders-49034.patch

Valentin Deniaud, 09 décembre 2020 10:43

Télécharger (6,11 ko)

Voir les différences:

Subject: [PATCH] agendas: include event description in reminders (#49034)

 .../templates/agendas/events_reminder_body.html    | 12 ++++++++++++
 .../templates/agendas/events_reminder_body.txt     |  9 +++++++++
 chrono/manager/views.py                            |  7 +++++--
 tests/test_agendas.py                              | 14 +++++++++++++-
 tests/test_manager.py                              |  7 +++++--
 5 files changed, 44 insertions(+), 5 deletions(-)
chrono/agendas/templates/agendas/events_reminder_body.html
10 10
{% endblocktrans %}
11 11
</p>
12 12

  
13
{% if booking.event.description %}
14
<p>{{ booking.event.description }}</p>
15
{% endif %}
16

  
17
{% if booking.event.pricing %}
18
<p>{% trans "Pricing:" %} {{ booking.event.pricing }}</p>
19
{% endif %}
20

  
21
{% if booking.event.url %}
22
<p>{% trans "Details:" %} <a href="{{ booking.event.url }}">{{ booking.event.url }}</a></p>
23
{% endif %}
24

  
13 25
{% if email_extra_info %}
14 26
<p>{{ email_extra_info }}</p>
15 27
{% endif %}
chrono/agendas/templates/agendas/events_reminder_body.txt
6 6
{% blocktrans trimmed with event=booking.event date=date|date:"l j F" time=date|time %}
7 7
You have a booking for event "{{ event }}", on {{ date }} at {{ time }}.
8 8
{% endblocktrans %}
9
{% if booking.event.description %}
10
{{ booking.event.description }}
11
{% endif %}
12
{% if booking.event.pricing %}
13
{% trans "Pricing:" %} {{ booking.event.pricing }}
14
{% endif %}
15
{% if booking.event.url %}
16
{% trans "Details:" %} {{ booking.event.url }}
17
{% endif %}
9 18
{% if email_extra_info %}
10 19
{{ email_extra_info }}
11 20
{% endif %}
chrono/manager/views.py
33 33
from django.urls import reverse, reverse_lazy
34 34
from django.utils.dates import MONTHS
35 35
from django.utils.timezone import now, make_aware, make_naive, localtime
36
from django.utils.translation import ugettext_lazy as _
36
from django.utils.translation import ugettext_lazy as _, gettext
37 37
from django.utils.translation import ungettext
38 38
from django.utils.encoding import force_text
39 39
from django.views.generic import (
......
1587 1587
        days = self.agenda.reminder_settings.days
1588 1588

  
1589 1589
        event = Event(
1590
            label='{{ event_label }}',
1590
            label=gettext('Event label'),
1591 1591
            start_datetime=datetime.datetime(year=2020, month=6, day=2, hour=14, minute=30),
1592
            description=_('This is the description of the event, if there is one.'),
1593
            pricing='10€',
1594
            url=_('https://url_of_event'),
1592 1595
        )
1593 1596
        booking = Booking(user_display_label='{{ user_display_label }}', form_url='#')
1594 1597
        booking.event = event
tests/test_agendas.py
1491 1491
        agenda=agenda, days=1, send_email=True, email_extra_info='Do no forget ID card.'
1492 1492
    )
1493 1493
    start_datetime = now() + datetime.timedelta(days=2)
1494
    event = Event.objects.create(agenda=agenda, start_datetime=start_datetime, places=10, label='Pool party')
1494
    event = Event.objects.create(
1495
        agenda=agenda,
1496
        start_datetime=start_datetime,
1497
        places=10,
1498
        label='Pool party',
1499
        description='Come !',
1500
        url='https://example.party',
1501
        pricing='10€',
1502
    )
1495 1503

  
1496 1504
    booking = Booking.objects.create(event=event, user_email='t@test.org')
1497 1505

  
......
1504 1512
    for body in mail_bodies:
1505 1513
        assert 'Hi,' in body
1506 1514
        assert 'You have a booking for event "Pool party", on Friday 3 January at 2 p.m..' in body
1515
        assert 'Come !' in body
1516
        assert 'Pricing: 10€' in body
1507 1517
        assert 'Do no forget ID card.' in body
1508 1518
        assert not 'cancel' in body
1519
    assert 'Details: https://example.party' in mail_bodies[0]
1520
    assert 'Details: <a href="https://example.party">https://example.party</a>' in mail_bodies[1]
1509 1521
    mailoutbox.clear()
1510 1522

  
1511 1523
    freezer.move_to('2020-01-01 14:00')
tests/test_manager.py
4760 4760
    assert 'Users will receive the following email:' in resp.text
4761 4761
    assert len(resp.pyquery.find('p.email-subject')) == 1
4762 4762
    assert '<strong>Subject:</strong> Reminder for your booking tomorrow at 2:30 p.m.' in resp.text
4763
    assert 'You have a booking for event "{{ event_label }}", on Tuesday 2 June at 2:30 p.m..' in resp.text
4763
    assert 'You have a booking for event "Event label", on Tuesday 2 June at 2:30 p.m..' in resp.text
4764
    assert 'This is the description' in resp.text
4765
    assert '10€' in resp.text
4766
    assert 'https://url_of_event' in resp.text
4764 4767
    assert 'An ID will be required' in resp.text
4765 4768

  
4766 4769
    resp = resp.click('Return to settings')
4767 4770
    resp = resp.click('Preview SMS')
4768 4771
    assert 'Users will receive the following SMS:' in resp.text
4769 4772
    assert (
4770
        'Reminder: you have a booking for event "{{ event_label }}", on 02/06 at 2:30 p.m.. Take ID card.'
4773
        'Reminder: you have a booking for event "Event label", on 02/06 at 2:30 p.m.. Take ID card.'
4771 4774
        in resp.text
4772 4775
    )
4773 4776

  
4774
-