Skip to content

Commit

Permalink
Backend
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast committed Dec 7, 2023
1 parent b9b5426 commit f9d8dc6
Show file tree
Hide file tree
Showing 19 changed files with 890 additions and 509 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

from applications.enums import ApplicationStatus
from applications.models import Application
from messages.automatic_messages import send_email_to_applicant
from messages.automatic_messages import (
get_email_template_context,
render_email_template,
send_email_to_applicant,
)

APPLICATION_ABOUT_TO_BE_DELETED_MESSAGE = _(
"Your application {id} will be deleted soon. If you want to continue the application process, please do so by "
Expand Down Expand Up @@ -48,12 +52,7 @@ def notify_applications(days_to_deletion: int, days_to_keep: int) -> int:

applications_to_notify = Application.objects.filter(
status=ApplicationStatus.DRAFT,
modified_at__lte=(
timezone.now() - timedelta(days=(days_to_keep - days_to_deletion))
),
modified_at__gte=(
timezone.now() - timedelta(days=(days_to_keep - days_to_deletion + 1))
),
modified_at__lte=(timezone.now()),
)

for application in applications_to_notify:
Expand All @@ -65,14 +64,20 @@ def notify_applications(days_to_deletion: int, days_to_keep: int) -> int:
def _send_notification_mail(application: Application, days_to_deletion: int) -> int:
"""Send a notification mail to the applicant about the upcoming application deletion"""

subject = _("Your application is about to be deleted")
application_deletion_date = (
application.modified_at + timedelta(days=days_to_deletion)
).strftime("%d.%m.%Y")

message = format_lazy(
format_lazy(
APPLICATION_ABOUT_TO_BE_DELETED_MESSAGE,
id=application.application_number,
application_deletion_date=(
application.modified_at + timedelta(days=days_to_deletion)
).strftime("%d.%m.%Y"),
application_deletion_date=application_deletion_date,
)

return send_email_to_applicant(application, subject, message)
subject = _("Your application is about to be deleted")
context = get_email_template_context(application)
context["application_deletion_date"] = application_deletion_date
message = render_email_template(context, "draft-notice", "txt")
html_message = render_email_template(context, "draft-notice", "html")

return send_email_to_applicant(application, subject, message, html_message)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<!-- ### NEVER MAKE MODIFICATIONS TO THIS GENERATED HTML DIRECTLY ### -->
<!-- ### ALL MODIFICATIONS SHOULD BE DONE TO MJML TEMPLATE FILES! ### -->
<title>Hakemuksesi tarvitsee lisätietoja</title>
<title>Your application requires additional information</title>
<!--[if !mso]><!-->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--<![endif]-->
Expand Down Expand Up @@ -106,8 +106,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:15px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>Helsinki-lisä: Hakemuksesi tarvitsee lisätietoja</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:15px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>Helsinki benefit: Your application requires additional information</div>

</td>
</tr>
Expand Down Expand Up @@ -149,26 +149,58 @@
border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"
>
<tbody>

<tr>
<td
align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"
>
<table
cellpadding="0" cellspacing="0" width="100%" border="0" style="color:#222222;font-family:HelsinkiGrotesk;font-size:16px;line-height:22px;table-layout:auto;width:100%;border:none;"
<table
border="0"
cellpadding="0"
cellspacing="0"
role="presentation"
style="vertical-align: top"
width="100%"
height="80"
>
<tr>
<td style="width: 146px">
<img src="https://makasiini.hel.ninja/helsinki-logos/helsinki-logo-black.png" width="130px" />
</td>
<td style="font-size: 26px; font-weight: 600; line-height: 1 padding-bottom: 8px;">Helsinki-lisä</td>
</tr>
<tbody>
<tr>
<td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word">
<table
cellpadding="0"
cellspacing="0"
role="presentation"
width="100%"
border="0"
height="80"
style="
color: #222222;
font-family: HelsinkiGrotesk, system-ui, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 1;
table-layout: auto;
width: 100%;
border: 0;
"
>
<tbody>
<tr height="66">
<td width="146" height="66" style="width: 146px; height: 60px">
<img
src="https://makasiini.hel.ninja/helsinki-logos/helsinki-logo-black.png"
style="width: 130px; height: 60px; margin: 0; padding: 0"
width="130"
height="60"
/>
</td>
<td
height="66"
style="font-size: 26px; font-weight: 600; line-height: 1; padding-bottom: 8px; height: 66px"
>
Helsinki-lisä
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>

</td>
</tr>

</tbody>
</table>

Expand Down Expand Up @@ -213,8 +245,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:34px;font-weight:600;line-height:150%;text-align:left;color:#222222;"
>Helsinki-lisä -hakemus tarvitsee lisätietoja</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:34px;font-weight:600;line-height:150%;text-align:left;color:#222222;"
>Your Helsinki benefit application requires additional information</div>

</td>
</tr>
Expand Down Expand Up @@ -242,8 +274,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>Hei!</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>Hello!</div>

</td>
</tr>
Expand All @@ -254,8 +286,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>Lähettämästäsi Helsinki-lisä-hakemuksesta puttu tarvittavia tietoia. Kiriaudu Helsinki-lisän asiointipalveluun ja täytä puttuvat tiedot {{ additional_information_deadline.date }} klo {{ additional_information_deadline.time }} mennessä.</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>The Helsinki benefit application you submitted is missing required information. Log in to the Helsinki benefit service and fill in the missing information by {{ additional_information_deadline_time }} on {{ additional_information_deadline_date }}.</div>

</td>
</tr>
Expand Down Expand Up @@ -304,8 +336,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>Mikäli sinulla herää kysyttävää, lähetä meille viesti Helsinki-lisän asiointipalvelun kautta.</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>If you have any questions, please send us a message via the Helsinki benefit e-service.</div>

</td>
</tr>
Expand Down Expand Up @@ -354,8 +386,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:16px;font-weight:400;line-height:100%;text-align:left;color:#222222;"
>Ystävällisin terveisin,</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:16px;font-weight:400;line-height:100%;text-align:left;color:#222222;"
>Best regards,</div>

</td>
</tr>
Expand All @@ -366,8 +398,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:16px;font-weight:400;line-height:100%;text-align:left;color:#222222;"
>Helsinki-lisän tiimi</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:16px;font-weight:400;line-height:100%;text-align:left;color:#222222;"
>The Helsinki benefit team</div>

</td>
</tr>
Expand Down Expand Up @@ -416,8 +448,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:18px;font-weight:600;line-height:150%;text-align:left;color:#222222;"
>Hakemuksen tiedot</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:18px;font-weight:600;line-height:150%;text-align:left;color:#222222;"
>Application details</div>

</td>
</tr>
Expand All @@ -428,22 +460,22 @@
>

<table
cellpadding="0" cellspacing="0" width="100%" border="0" style="color:#222222;font-family:HelsinkiGrotesk;font-size:15px;line-height:22px;table-layout:auto;width:100%;border:none;"
cellpadding="0" cellspacing="0" width="100%" border="0" style="color:#222222;font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:15px;line-height:22px;table-layout:auto;width:100%;border:none;"
>
<tr style="border-top: 1px solid #ecedee; border-bottom: 1px solid #ecedee; text-align: left">
<td style="padding: 15px 0">Hakemusnumero</td>
<td style="padding: 15px 0">Application number</td>
<td style="padding: 15px 0; text-align: right">{{ application.application_number }}</td>
</tr>
<tr style="border-bottom: 1px solid #ecedee">
<td style="padding: 15px 0">Hakemuksen tila</td>
<td style="padding: 15px 0">Application status</td>
<td style="padding: 15px 0; text-align: right">
<span style="background: #fef4d4; padding: 7px 14px"
>Odottaa lisätietoja</span
>Additional information required</span
>
</td>
</tr>
<tr style="border-bottom: 1px solid #ecedee">
<td style="padding: 15px 0">Hakemuksen lähetyspäivä</td>
<td style="padding: 15px 0">Application submission date</td>
<td style="padding: 15px 0; text-align: right">{{ application.created_at }}</td>
</tr>
</table>
Expand Down Expand Up @@ -503,9 +535,9 @@
align="center" bgcolor="#0072c6" role="presentation" style="border:none;border-radius:0;cursor:auto;mso-padding-alt:16px 32px;background:#0072c6;" valign="middle"
>
<a
href="https://helsinkilisa.hel.fi" style="display:inline-block;background:#0072c6;color:#FFFFFF;font-family:HelsinkiGrotesk;font-size:16px;font-weight:normal;line-height:120%;margin:0;text-decoration:none;text-transform:none;padding:16px 32px;mso-padding-alt:0px;border-radius:0;" target="_blank"
href="https://helsinkilisa.hel.fi" style="display:inline-block;background:#0072c6;color:#FFFFFF;font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:16px;font-weight:normal;line-height:120%;margin:0;text-decoration:none;text-transform:none;padding:16px 32px;mso-padding-alt:0px;border-radius:0;" target="_blank"
>
Kirjaudu palveluun ja täydennä hakemusta
Log in and complete your application
</a>
</td>
</tr>
Expand Down Expand Up @@ -571,8 +603,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:14px;font-weight:400;line-height:150%;text-align:left;color:#666666;"
>Tämä on automaattinen ilmoitus sinulle lähetetystä verkkoviestistä. Ethän vastaa tähän sähköpostiin, sillä vastauksia ei käsitellä. Ota tarvittaessa yhteyttä neuvontaan sähköpostitse [email protected].</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:14px;font-weight:400;line-height:150%;text-align:left;color:#666666;"
>This is an automatic notification of an online message sent to you. Please do not reply to this message, as responses will not be processed. Please do not hesitate to contact the advisory service by e-mail at [email protected].</div>

</td>
</tr>
Expand Down Expand Up @@ -641,8 +673,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:20px;font-weight:600;line-height:150%;text-align:left;color:#222222;"
>Helsinki-lisä</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:20px;font-weight:600;line-height:150%;text-align:left;color:#222222;"
>Helsinki benefit</div>

</td>
</tr>
Expand Down Expand Up @@ -682,8 +714,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
><a href="#">Tietoa Helsinki-lisästä</a></div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
><a href="#">Information about the Helsinki benefit</a></div>

</td>
</tr>
Expand All @@ -694,8 +726,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
><a href="#">Asiakaspalvelu ja yhteystiedot</a></div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
><a href="#">Customer service and contact details</a></div>

</td>
</tr>
Expand Down Expand Up @@ -735,8 +767,8 @@
>

<div
style="font-family:HelsinkiGrotesk;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>© Helsingin kaupunki {{current_year}}</div>
style="font-family:HelsinkiGrotesk,system-ui,sans-serif;font-size:16px;font-weight:400;line-height:150%;text-align:left;color:#222222;"
>© City of Helsinki {{current_year}}</div>

</td>
</tr>
Expand Down
Loading

0 comments on commit f9d8dc6

Please sign in to comment.