Skip to content

Commit

Permalink
Email: Add emails for STAFF_NOTIFICATION_APPLICATION_SECTION_CANCELLED
Browse files Browse the repository at this point in the history
  • Loading branch information
ranta committed Dec 12, 2024
1 parent 1dac24d commit bda927b
Show file tree
Hide file tree
Showing 16 changed files with 474 additions and 23 deletions.
36 changes: 26 additions & 10 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,11 @@ msgctxt "EmailType"
msgid "Seasonal reservation rejected single"
msgstr "Kausivaraus hylätty yksittäinen"

#: tilavarauspalvelu/enums.py
msgctxt "EmailType"
msgid "Staff notification application section cancelled"
msgstr "Käsittelijä ilmoitus kausivaraushakemuksen osan perumisesta"

#: tilavarauspalvelu/enums.py
msgctxt "EmailType"
msgid "Staff notification reservation made"
Expand Down Expand Up @@ -2948,16 +2953,22 @@ msgid "Seasonal Booking"
msgstr "Kausivaraus"

#: tilavarauspalvelu/integrations/email/template_context/application.py
#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "Day"
msgstr "Päivä"
msgid "The customer has canceled the seasonal booking"
msgstr "Asiakas on perunut kausivarauksen"

#: tilavarauspalvelu/integrations/email/template_context/application.py
msgctxt "Email"
msgid ""
"The customer has canceled all space reservations included in the seasonal "
"booking"
msgstr "Asiakas on perunut kaikki kausivaraukseen kuuluvat tilavaraukset"

#: tilavarauspalvelu/integrations/email/template_context/application.py
#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "Time"
msgstr "Kellonaika"
msgid "You can view the booking at"
msgstr "Voit tarkistaa varauksen tiedot osoitteessa"

#: tilavarauspalvelu/integrations/email/template_context/common.py
msgctxt "Email"
Expand Down Expand Up @@ -3203,6 +3214,16 @@ msgid ""
"changed"
msgstr "Kausivaraukseesi kuuluvan tilavarauksen ajankohta on muuttunut"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "Day"
msgstr "Päivä"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "Time"
msgstr "Kellonaika"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
#, python-format
msgctxt "Email"
Expand All @@ -3222,11 +3243,6 @@ msgctxt "Email"
msgid "Reservee name"
msgstr "Varaajan nimi"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "You can view the booking at"
msgstr "Voit tarkistaa varauksen tiedot osoitteessa"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
#, python-format
msgctxt "Email"
Expand Down
36 changes: 26 additions & 10 deletions locale/sv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,11 @@ msgctxt "EmailType"
msgid "Seasonal reservation rejected single"
msgstr ""

#: tilavarauspalvelu/enums.py
msgctxt "EmailType"
msgid "Staff notification application section cancelled"
msgstr ""

#: tilavarauspalvelu/enums.py
msgctxt "EmailType"
msgid "Staff notification reservation made"
Expand Down Expand Up @@ -2884,16 +2889,22 @@ msgid "Seasonal Booking"
msgstr "Säsongsbokning"

#: tilavarauspalvelu/integrations/email/template_context/application.py
#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "Day"
msgstr "Dag"
msgid "The customer has canceled the seasonal booking"
msgstr "Kunden har avbokat säsongsbokningen"

#: tilavarauspalvelu/integrations/email/template_context/application.py
msgctxt "Email"
msgid ""
"The customer has canceled all space reservations included in the seasonal "
"booking"
msgstr "Kunden har avbokat alla lokalbokningar som ingår i säsongsbokningen"

#: tilavarauspalvelu/integrations/email/template_context/application.py
#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "Time"
msgstr "Tid"
msgid "You can view the booking at"
msgstr "Du kan se bokningen på"

#: tilavarauspalvelu/integrations/email/template_context/common.py
msgctxt "Email"
Expand Down Expand Up @@ -3140,6 +3151,16 @@ msgid ""
"changed"
msgstr "Tiden för lokalbokningen som ingår i din säsongsbokning har ändrats"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "Day"
msgstr "Dag"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "Time"
msgstr "Tid"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
#, python-format
msgctxt "Email"
Expand All @@ -3157,11 +3178,6 @@ msgctxt "Email"
msgid "Reservee name"
msgstr "Bokare"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
msgctxt "Email"
msgid "You can view the booking at"
msgstr "Du kan se bokningen på"

#: tilavarauspalvelu/integrations/email/template_context/reservation.py
#, python-format
msgctxt "Email"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<mj-spacer />

<mj-text font-size="16px">{{ seasonal_booking_label | safe}}: {{ application_section_name | safe }}, {{ application_round_name | safe }}</mj-text>
<mj-text>{{ seasonal_booking_label | safe}}: {{ application_section_name | safe }}, {{ application_round_name | safe }}</mj-text>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends "email/html/partials/base.jinja" %}

{% block content_main %}
<mj-text>{{ text_reservation_cancelled | sentence | safe }}</mj-text>
<mj-text>{{ cancel_reason_label | safe }}: {{ cancel_reason | safe }}</mj-text>
{% include "email/html/partials/application_section_name.jinja" %}

<mj-spacer />
<mj-text>{{ view_booking_at_label | safe }}:</mj-text>
{% for series in cancelled_reservation_series %}
<mj-text>{{ series.weekday | safe }}: {{ series.time | safe }}</mj-text>
<mj-text><a href="{{ series.url | safe }}">{{ series.url | safe }}</a></mj-text>
{% endfor %}
{% endblock %}

{% block content_secondary %}{% endblock %}

{% block content_closing %}
{% include "email/html/partials/closing_staff.jinja" %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ salutation | safe }},

{{ text_reservation_cancelled | sentence | safe }}

{{ cancel_reason_label | safe }}: {{ cancel_reason | safe }}

{% include "email/text/partials/application_section_name.jinja" %}

{{ view_booking_at_label | safe }}:

{% for series in cancelled_reservation_series %}{{ series.weekday | safe }} {{ series.time | safe }}
{{ series.url | safe }}
{% endfor %}
{% include "email/text/partials/closing_staff.jinja" %}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from freezegun import freeze_time

from tilavarauspalvelu.enums import ReservationStateChoice, ReservationTypeChoice
from tilavarauspalvelu.integrations.email.main import EmailService
from utils.date_utils import local_date, local_datetime

from tests.factories import (
Expand All @@ -14,6 +15,7 @@
ReservationCancelReasonFactory,
UserFactory,
)
from tests.helpers import patch_method

from .helpers import CANCEL_SECTION_SERIES_MUTATION, create_reservation_series

Expand All @@ -23,6 +25,8 @@
]


@patch_method(EmailService.send_application_section_cancelled)
@patch_method(EmailService.send_staff_notification_application_section_cancelled)
@freeze_time(local_datetime(year=2024, month=1, day=1))
def test_recurring_reservations__cancel_section_series__cancel_whole_remaining(graphql):
reason = ReservationCancelReasonFactory.create()
Expand Down Expand Up @@ -59,6 +63,9 @@ def test_recurring_reservations__cancel_section_series__cancel_whole_remaining(g
assert response.first_query_object == {"cancelled": 5, "future": 5}
assert reservation_series.reservations.count() == 9

assert EmailService.send_application_section_cancelled.called is True
assert EmailService.send_staff_notification_application_section_cancelled.called is True


@freeze_time(local_datetime(year=2024, month=1, day=1))
def test_recurring_reservations__cancel_section_series__cancel_details_not_required(graphql):
Expand Down
125 changes: 125 additions & 0 deletions tests/test_integrations/test_email/test_application_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
get_context_for_application_received,
get_context_for_application_section_cancelled,
)
from tilavarauspalvelu.integrations.email.template_context.application import (
get_context_for_staff_notification_application_section_cancelled,
)

from tests.helpers import TranslationsFromPOFiles
from tests.test_integrations.test_email.helpers import (
Expand All @@ -24,6 +27,9 @@
CLOSING_POLITE_CONTEXT_EN,
CLOSING_POLITE_CONTEXT_FI,
CLOSING_POLITE_CONTEXT_SV,
CLOSING_STAFF_CONTEXT_EN,
CLOSING_STAFF_CONTEXT_FI,
CLOSING_STAFF_CONTEXT_SV,
SEASONAL_RESERVATION_CHECK_BOOKING_DETAILS_LINK_EN,
SEASONAL_RESERVATION_CHECK_BOOKING_DETAILS_LINK_FI,
SEASONAL_RESERVATION_CHECK_BOOKING_DETAILS_LINK_SV,
Expand Down Expand Up @@ -348,3 +354,122 @@ def test_get_context_for_application_section_cancelled_sv():
**CLOSING_CONTEXT_SV,
**AUTOMATIC_REPLY_CONTEXT_SV,
}


# type: EmailType.STAFF_NOTIFICATION_APPLICATION_SECTION_CANCELLED #####################################################


@freeze_time("2024-01-01")
def test_get_context_for_staff_notification_application_section_cancelled__en():
with TranslationsFromPOFiles():
context = get_context_for_staff_notification_application_section_cancelled(
application_section_name="[HAKEMUKSEN OSAN NIMI]",
application_round_name="[KAUSIVARAUSKIERROKSEN NIMI]",
cancel_reason="[PERUUTUKSEN SYY]",
language="en",
)

assert context == {
"email_recipient_name": None,
"title": "The customer has canceled the seasonal booking",
"text_reservation_cancelled": (
"The customer has canceled all space reservations included in the seasonal booking"
),
"seasonal_booking_label": "Seasonal Booking",
"application_section_name": "[HAKEMUKSEN OSAN NIMI]",
"application_round_name": "[KAUSIVARAUSKIERROKSEN NIMI]",
"cancel_reason_label": "Reason",
"cancel_reason": "[PERUUTUKSEN SYY]",
"view_booking_at_label": "You can view the booking at",
"cancelled_reservation_series": [
{
"weekday": "Monday",
"time": "13:00-15:00",
"url": "https://fake.varaamo.hel.fi/kasittely/reservations/1234",
},
{
"weekday": "Tuesday",
"time": "21:00-22:00",
"url": "https://fake.varaamo.hel.fi/kasittely/reservations/5678",
},
],
**BASE_TEMPLATE_CONTEXT_EN,
**CLOSING_CONTEXT_EN,
**CLOSING_STAFF_CONTEXT_EN,
}


@freeze_time("2024-01-01")
def test_get_context_for_staff_notification_application_section_cancelled__fi():
with TranslationsFromPOFiles():
context = get_context_for_staff_notification_application_section_cancelled(
application_section_name="[HAKEMUKSEN OSAN NIMI]",
application_round_name="[KAUSIVARAUSKIERROKSEN NIMI]",
cancel_reason="[PERUUTUKSEN SYY]",
language="fi",
)

assert context == {
"email_recipient_name": None,
"title": "Asiakas on perunut kausivarauksen",
"text_reservation_cancelled": "Asiakas on perunut kaikki kausivaraukseen kuuluvat tilavaraukset",
"seasonal_booking_label": "Kausivaraus",
"application_section_name": "[HAKEMUKSEN OSAN NIMI]",
"application_round_name": "[KAUSIVARAUSKIERROKSEN NIMI]",
"cancel_reason_label": "Syy",
"cancel_reason": "[PERUUTUKSEN SYY]",
"view_booking_at_label": "Voit tarkistaa varauksen tiedot osoitteessa",
"cancelled_reservation_series": [
{
"weekday": "Monday",
"time": "13:00-15:00",
"url": "https://fake.varaamo.hel.fi/kasittely/reservations/1234",
},
{
"weekday": "Tuesday",
"time": "21:00-22:00",
"url": "https://fake.varaamo.hel.fi/kasittely/reservations/5678",
},
],
**BASE_TEMPLATE_CONTEXT_FI,
**CLOSING_CONTEXT_FI,
**CLOSING_STAFF_CONTEXT_FI,
}


@freeze_time("2024-01-01")
def test_get_context_for_staff_notification_application_section_cancelled_sv():
with TranslationsFromPOFiles():
context = get_context_for_staff_notification_application_section_cancelled(
application_section_name="[HAKEMUKSEN OSAN NIMI]",
application_round_name="[KAUSIVARAUSKIERROKSEN NIMI]",
cancel_reason="[PERUUTUKSEN SYY]",
language="sv",
)

assert context == {
"email_recipient_name": None,
"title": "Kunden har avbokat säsongsbokningen",
"text_reservation_cancelled": "Kunden har avbokat alla lokalbokningar som ingår i säsongsbokningen",
"seasonal_booking_label": "Säsongsbokning",
"application_section_name": "[HAKEMUKSEN OSAN NIMI]",
"application_round_name": "[KAUSIVARAUSKIERROKSEN NIMI]",
"cancel_reason_label": "Orsak",
"cancel_reason": "[PERUUTUKSEN SYY]",
"view_booking_at_label": "Du kan se bokningen på",
"cancelled_reservation_series": [
{
"weekday": "Monday",
"time": "13:00-15:00",
"url": "https://fake.varaamo.hel.fi/kasittely/reservations/1234",
},
{
"weekday": "Tuesday",
"time": "21:00-22:00",
"url": "https://fake.varaamo.hel.fi/kasittely/reservations/5678",
},
],
**BASE_TEMPLATE_CONTEXT_SV,
**CLOSING_CONTEXT_SV,
**CLOSING_STAFF_CONTEXT_SV,
}
Loading

0 comments on commit bda927b

Please sign in to comment.