-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
alert dev team when pipeline encounters permission errors (#1447)
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
designsafe/apps/api/projects_v2/operations/project_email_operations.py
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,36 @@ | ||
"""Utilities to email users/staff in response to project lifecycle changes.""" | ||
|
||
from typing import Optional | ||
from django.conf import settings | ||
from django.core.mail import send_mail | ||
|
||
|
||
def send_project_permissions_alert(project_id: str, version: Optional[int], error: str): | ||
""" | ||
Alert dev team when a project has encountered a permission error during publication. | ||
""" | ||
prj_admins = settings.DEV_PROJECT_ADMINS_EMAIL | ||
for admin in prj_admins: | ||
email_body = f""" | ||
<p>Hello,</p> | ||
<p> | ||
The following project has encountered a permission error during publication: | ||
<br/> | ||
<b>{project_id} - revision {version}</b> | ||
<br/> | ||
</p> | ||
<p> | ||
The error is as follows:<br/> | ||
{error} | ||
</p> | ||
This is a programmatically generated message. Do NOT reply to this message. | ||
""" | ||
|
||
send_mail( | ||
"DesignSafe Alert: Published Project has missing files/folders", | ||
email_body, | ||
settings.DEFAULT_FROM_EMAIL, | ||
[admin], | ||
html_message=email_body, | ||
) |
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