Add email preview functionality for candidate details: allow users to preview email content before sending
This commit is contained in:
+33
-21
@@ -1552,27 +1552,9 @@ class CidUser(models.Model):
|
||||
if self.login_email_sent and not resend:
|
||||
return False, "Already sent."
|
||||
|
||||
login_url = reverse("cid_selector")
|
||||
|
||||
msg = f"""
|
||||
See below for your details for: {self.group}
|
||||
|
||||
---------
|
||||
CID: {self.cid}
|
||||
Passcode: {self.passcode}
|
||||
---------
|
||||
|
||||
You will need these to access to the test system.
|
||||
|
||||
Direct link to login:
|
||||
{settings.REMOTE_URL}{login_url}?cid={self.cid}&passcode={self.passcode}
|
||||
|
||||
The above details are unique to you. Please do not share as otherwise others will be able to access and submit your results.
|
||||
|
||||
|
||||
|
||||
Please note this inbox is not monitored. Direct all enquiries to plh-tr.radiology-academy@nhs.net
|
||||
"""
|
||||
# Build the message payload. Exposed as a separate method so callers
|
||||
# can preview the email without actually sending it.
|
||||
msg = self.generate_email_details_msg()
|
||||
|
||||
try:
|
||||
# send_mail(
|
||||
@@ -1597,6 +1579,36 @@ class CidUser(models.Model):
|
||||
self.save()
|
||||
return True, ""
|
||||
|
||||
def generate_email_details_msg(self) -> str:
|
||||
"""Generate the candidate details email body without sending it.
|
||||
|
||||
Returns:
|
||||
str: The plaintext email body that would be sent.
|
||||
"""
|
||||
login_url = reverse("cid_selector")
|
||||
|
||||
msg = f"""
|
||||
See below for your details for: {self.group}
|
||||
|
||||
---------
|
||||
CID: {self.cid}
|
||||
Passcode: {self.passcode}
|
||||
---------
|
||||
|
||||
You will need these to access to the test system.
|
||||
|
||||
Direct link to login:
|
||||
{settings.REMOTE_URL}{login_url}?cid={self.cid}&passcode={self.passcode}
|
||||
|
||||
The above details are unique to you. Please do not share as otherwise others will be able to access and submit your results.
|
||||
|
||||
|
||||
|
||||
Please note this inbox is not monitored. Direct all enquiries to plh-tr.radiology-academy@nhs.net
|
||||
"""
|
||||
|
||||
return msg
|
||||
|
||||
def get_email_details_url(self):
|
||||
return reverse("generic:candidate_email_details", kwargs={"cid": self.cid})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user