Skip to content

notify

main.notify ¤

Function to send notifications to user and HoRSE.

Functions¤

email_attachment(subject, email, message, attachment_fname, attachment, attachment_type) ¤

Send email with attachment to HoRSEs.

Source code in main/notify.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def email_attachment(
    subject: str,
    email: list[str],
    message: str,
    attachment_fname: str,
    attachment: str,
    attachment_type: str,
) -> None:
    """Send email with attachment to HoRSEs."""
    email_message = EmailMessage(
        subject=subject,
        body=message,
        from_email=None,
        to=email,
    )
    email_message.attach(
        filename=attachment_fname, content=attachment, mimetype=attachment_type
    )
    email_message.send(fail_silently=False)

email_user(subject, email, message) ¤

Send email notification to the project lead.

Source code in main/notify.py
 6
 7
 8
 9
10
11
12
13
14
def email_user(subject: str, email: str, message: str) -> None:
    """Send email notification to the project lead."""
    send_mail(
        subject=subject,
        message=message,
        from_email=None,
        recipient_list=[email],
        fail_silently=False,
    )

email_user_and_cc_head(subject, email, head_email, message) ¤

Send email notification to the project lead and CC HoRSE.

Source code in main/notify.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def email_user_and_cc_head(
    subject: str,
    email: str,
    head_email: list[str] | str,
    message: str,
) -> None:
    """Send email notification to the project lead and CC HoRSE."""
    cc_list = [head_email] if isinstance(head_email, str) else head_email
    email_message = EmailMessage(
        subject=subject,
        body=message,
        from_email=None,
        to=[email],
        cc=cc_list,
    )
    email_message.send(fail_silently=False)