-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* FEAT #513: Implement email reminders to complete risk assessments * Add missing f-string tag
- Loading branch information
1 parent
37101d3
commit 0117091
Showing
14 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import premailer | ||
import datetime | ||
|
||
from django.template.loader import get_template | ||
from django.contrib.staticfiles import finders | ||
from django.conf import settings | ||
from django.core.management.base import BaseCommand, CommandError | ||
from django.core.mail import EmailMultiAlternatives | ||
from django.utils import timezone | ||
from django.urls import reverse | ||
|
||
from RIGS import models | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Sends email reminders as required. Triggered daily through heroku-scheduler in production.' | ||
|
||
def handle(self, *args, **options): | ||
events = models.Event.objects.current_events().select_related('riskassessment') | ||
for event in events: | ||
earliest_time = event.earliest_time if isinstance(event.earliest_time, datetime.datetime) else timezone.make_aware(datetime.datetime.combine(event.earliest_time, datetime.time(00, 00))) | ||
# 48 hours = 172800 seconds | ||
if not event.cancelled and not event.dry_hire and (earliest_time - timezone.now()).total_seconds() <= 172800 and not hasattr(event, 'riskassessment'): | ||
context = { | ||
"event": event, | ||
"url": "https://" + settings.DOMAIN + reverse('event_ra', kwargs={'pk': event.pk}) | ||
} | ||
target = event.mic.email if event.mic else f"productions@{settings.DOMAIN}" | ||
msg = EmailMultiAlternatives( | ||
f"{event} - Risk Assessment Incomplete", | ||
get_template("email/ra_reminder.txt").render(context), | ||
to=[target], | ||
reply_to=[f"h.s.manager@{settings.DOMAIN}"], | ||
) | ||
css = finders.find('css/email.css') | ||
html = premailer.Premailer(get_template("email/ra_reminder.html").render(context), external_styles=css).transform() | ||
msg.attach_alternative(html, 'text/html') | ||
msg.send() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Hi {{object.event.mic.get_full_name|default_if_none:"somebody"}}, | ||
|
||
Just to let you know your event N{{object.eventdisplay_id}} has been successfully authorised for £{{object.amount}} by {{object.name}} as of {{object.event.last_edited_at}}. | ||
|
||
The TEC Rig Information Gathering System |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% extends 'base_client_email.html' %} | ||
|
||
{% block content %} | ||
<p>Hi {{event.mic.get_full_name|default_if_none:"Productions Manager"}},</p> | ||
|
||
{% if event.mic %} | ||
<p>Just to let you know your event {{event.display_id}} <em>requires<em> a pre-event risk assessment completing prior to the event. Please do so as soon as possible.</p> | ||
{% else %} | ||
<p>This is a reminder that event {{event.display_id}} requires a MIC assigning and a risk assessment completing.</p> | ||
{% endif %} | ||
|
||
<p>Fill it out here:</p> | ||
<a href="{{url}}" class="btn btn-info"><span class="fas fa-paperclip"></span> Create Risk Assessment</a> | ||
|
||
<p>TEC PA & Lighting</p> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Hi {{event.mic.get_full_name|default_if_none:"Productions Manager"}}, | ||
|
||
{% if event.mic %} | ||
Just to let you know your event {{event.display_id}} requires a risk assessment completing prior to the event. Please do so as soon as possible. | ||
{% else %} | ||
This is a reminder that event {{event.display_id}} requires a MIC assigning and a risk assessment completing. | ||
{% endif %} | ||
|
||
The TEC Rig Information Gathering System |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters