Skip to content

Commit

Permalink
fix: adjusted links to hpc access in outgoing emails (#140) (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
stolpeo authored May 25, 2023
1 parent f84fb11 commit 5a2e1bb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 56 deletions.
96 changes: 41 additions & 55 deletions adminsec/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
USER_GREETING = "Dear {user},"

#: Greeting for admin emails
ADMIN_GREETING = "Dear admins"
ADMIN_GREETING = "Dear admins,"

#: Greeting for emails with unknown recipient
NEUTRAL_GREETING = "Hello"
Expand All @@ -78,7 +78,7 @@
#: Email footer
FOOTER = r"""
Best regards,
The BIH HPC Team
The BIH HPC Team
(This email has been automatically generated.)
""".lstrip()
Expand All @@ -91,8 +91,8 @@
NOTIFICATION_ADMIN_REQUEST = r"""
{greeting}
a {request_type} request has been submitted by {username}.
Please visit the following link to review the request:
a {request_type} request has been submitted by {username}. Please visit the
following link to review the request:
{hpc_access_link}
Expand All @@ -108,9 +108,9 @@
NOTIFICATION_MANAGER_REQUEST = r"""
{greeting}
you have successfully requested a {project_or_group} on the BIH HPC cluster. It is now pending
approval by the HPC administrators. You can check the status of your request by visiting
the following link:
you have successfully requested a {project_or_group} on the BIH HPC cluster. It
is now pending approval by the HPC administrators. You can check the status of
your request by visiting the following link:
{hpc_access_link}
Expand All @@ -124,14 +124,14 @@
your group request has been approved and the group has been created.
You can now add members to your group, name a delegate or create projects.
Find more details in the manual:
You can now add members to your group, name a delegate or create projects. Find
more details in the manual:
{manual_link}
Your group folder is located at
{group_folder}
{group_folder}
{footer}
""".lstrip()
Expand All @@ -143,14 +143,14 @@
your project request has been approved and the project has been created.
You can now add members to your project from different other work group and also name a delegate.
Find more details in the manual:
You can now add members to your project from different other work group and
also name a delegate. Find more details in the manual:
{manual_link}
Your project folder is located at
{project_folder}
{project_folder}
{footer}
""".lstrip()
Expand Down Expand Up @@ -180,8 +180,8 @@
there is an update on your {request_type} request.
It hasn't been decided yet because more information is required.
Please visit the link below to revise your request:
It hasn't been decided yet because more information is required. Please visit
the link below to revise your request:
{hpc_access_link}
Expand All @@ -193,8 +193,8 @@
NOTIFICATION_MANAGER_REQUEST_DENIED = r"""
{greeting}
there is an update on your {request_type} request. Unfortunately, it has been declined.
Please find more information by following the link below:
there is an update on your {request_type} request. Unfortunately, it has been
declined. Please find more information by following the link below:
{hpc_access_link}
Expand All @@ -208,8 +208,8 @@
NOTIFICATION_MANAGER_CHANGE_REQUEST_APPROVED = r"""
{greeting}
your {request_type} request has been approved.
Please see the active changes by following the link below:
your {request_type} request has been approved. Please see the active changes
by following the link below:
{hpc_access_link}
Expand All @@ -224,21 +224,10 @@
NOTIFICATION_USER_GROUP_INVITATION = r"""
{greeting}
You've been invited by
You've been invited by {inviter} to become member of group {identifier} with
your username {username} on the BIH HPC cluster. Head over to
{inviter}
to become member of group
{identifier}
with your username
{username}
on the BIH HPC cluster. Head over to
{invitation_link}
{invitation_link}
and log in with your {institute} credentials. A page with a disclaimer will be shown.
Please read the text carefully. You can then accept or decline the invitation.
Expand All @@ -253,15 +242,8 @@
NOTIFICATION_USER_PROJECT_INVITATION = r"""
{greeting}
You've been invited by
{inviter}
to become member of project
{identifier}
on the BIH HPC cluster. Head over to
You've been invited by {inviter} to become member of project {identifier} on
the BIH HPC cluster. Head over to
{invitation_link}
Expand Down Expand Up @@ -386,9 +368,9 @@ def send_notification_admin_request(request):

subject = SUBJECT_ADMIN_REQUEST.format(request_type=request.get_request_type())
message = NOTIFICATION_ADMIN_REQUEST.format(
greeting=NEUTRAL_GREETING,
greeting=ADMIN_GREETING,
username=request.requester.name,
hpc_access_link=request.get_detail_path(admin=True),
hpc_access_link=HPC_ACCESS_LINK + request.get_detail_path(admin=True),
request_type=request.get_request_type(),
footer=FOOTER,
)
Expand All @@ -405,7 +387,7 @@ def send_notification_manager_group_request(request):
message = NOTIFICATION_MANAGER_REQUEST.format(
greeting=USER_GREETING.format(user=request.requester.name),
project_or_group=HPC_OBJECT_GROUP,
hpc_access_link=request.get_detail_path(),
hpc_access_link=HPC_ACCESS_LINK + request.get_detail_path(),
footer=FOOTER,
)
return send_mail(subject, message, [request.requester.email])
Expand All @@ -429,7 +411,7 @@ def send_notification_manager_project_request(request):
message = NOTIFICATION_MANAGER_REQUEST.format(
greeting=USER_GREETING.format(user=request.requester.name),
project_or_group=HPC_OBJECT_PROJECT,
hpc_access_link=request.get_detail_path(),
hpc_access_link=HPC_ACCESS_LINK + request.get_detail_path(),
footer=FOOTER,
)
return send_mail(subject, message, [request.requester.email])
Expand All @@ -453,7 +435,7 @@ def send_notification_manager_change_request_approved(request):
message = NOTIFICATION_MANAGER_CHANGE_REQUEST_APPROVED.format(
greeting=USER_GREETING.format(user=request.requester.name),
request_type=request.get_request_type(),
hpc_access_link=request.get_detail_path(),
hpc_access_link=HPC_ACCESS_LINK + request.get_detail_path(),
footer=FOOTER,
)
return send_mail(subject, message, [request.requester.email])
Expand All @@ -464,13 +446,15 @@ def send_notification_manager_user_decided_invitation(invitation):
username = UNDEFINED_VARIABLE
project_or_group = UNDEFINED_VARIABLE
account_created = ""
emails = []
email = ""
requester_name = UNDEFINED_VARIABLE

if isinstance(invitation, HpcGroupInvitation):
identifier = invitation.hpcusercreaterequest.group.name
username = invitation.username
project_or_group = HPC_OBJECT_GROUP
emails = invitation.hpcusercreaterequest.requester.email
email = invitation.hpcusercreaterequest.requester.email
requester_name = invitation.hpcusercreaterequest.requester.name

if invitation.status == INVITATION_STATUS_ACCEPTED:
account_created = NOTIFICATION_PART_USER_ACCOUNT_CREATED
Expand All @@ -481,32 +465,34 @@ def send_notification_manager_user_decided_invitation(invitation):
project_or_group = HPC_OBJECT_PROJECT

if invitation.hpcprojectcreaterequest:
emails = invitation.hpcprojectcreaterequest.requester.email
email = invitation.hpcprojectcreaterequest.requester.email
requester_name = invitation.hpcprojectcreaterequest.requester.name

elif invitation.hpcprojectcreaterequest:
emails = invitation.hpcprojectcreaterequest.requester.email
email = invitation.hpcprojectcreaterequest.requester.email
requester_name = invitation.hpcprojectcreaterequest.requester.name

subject = SUBJECT_MANAGER_USER_DECIDED_INVITATION.format(
decision=invitation.status, project_or_group=project_or_group
)
message = NOTIFICATION_MANAGER_USER_DECIDED_INVITATION.format(
greeting=NEUTRAL_GREETING,
greeting=USER_GREETING.format(user=requester_name),
username=username,
decision=invitation.status,
project_or_group=project_or_group,
identifier=identifier,
account_created=account_created,
footer=FOOTER,
)
return send_mail(subject, message, [emails])
return send_mail(subject, message, [email])


def send_notification_manager_revision_required(request):
subject = SUBJECT_MANAGER_REVISE_REQUEST.format(request_type=request.get_request_type())
message = NOTIFICATION_MANAGER_REVISE_REQUEST.format(
greeting=USER_GREETING.format(user=request.requester.name),
request_type=request.get_request_type(),
hpc_access_link=request.get_detail_path(),
hpc_access_link=HPC_ACCESS_LINK + request.get_detail_path(),
footer=FOOTER,
)
return send_mail(subject, message, [request.requester.email])
Expand All @@ -517,7 +503,7 @@ def send_notification_manager_request_denied(request):
message = NOTIFICATION_MANAGER_REQUEST_DENIED.format(
greeting=USER_GREETING.format(user=request.requester.name),
request_type=request.get_request_type(),
hpc_access_link=request.get_detail_path(),
hpc_access_link=HPC_ACCESS_LINK + request.get_detail_path(),
footer=FOOTER,
)
return send_mail(subject, message, [request.requester.email])
Expand Down
2 changes: 1 addition & 1 deletion adminsec/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@


def get_admin_emails():
return [u.email for u in User.objects.filter(is_hpcadmin=True, email__isnull=False)]
return [u.email for u in User.objects.filter(is_hpcadmin=True) if u.email]


def ldap_to_hpc_username(username, domain):
Expand Down

0 comments on commit 5a2e1bb

Please sign in to comment.