Coverage for website/education/emails.py: 75.00%
8 statements
« prev ^ index » next coverage.py v7.6.7, created at 2025-08-14 10:31 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2025-08-14 10:31 +0000
1import logging
3from django.conf import settings
4from django.urls import reverse
6from utils.snippets import send_email
8logger = logging.getLogger(__name__)
11def send_document_notification(document):
12 """Send an email to a configured email.
14 :param document: The document we are sending the email for
15 """
16 admin_url = reverse(
17 f"admin:{document._meta.app_label}_{document._meta.model_name}_change",
18 args=(document.pk,),
19 )
21 send_email(
22 to=[settings.EDUCATION_NOTIFICATION_ADDRESS],
23 subject="Education document ready for review",
24 txt_template="education/email/document_notification.txt",
25 html_template="education/email/document_notification.html",
26 context={
27 "document": document.name,
28 "uploader": document.uploader.get_full_name(),
29 "url": settings.BASE_URL + admin_url,
30 "course": f"{document.course.name} ({document.course.course_code})",
31 },
32 )