Add email preview functionality for candidate details: allow users to preview email content before sending
This commit is contained in:
+17
-1
@@ -5043,8 +5043,24 @@ def candidate_email_details(request, cid, resend=False):
|
||||
except Exception:
|
||||
resend_flag = False
|
||||
|
||||
# Allow a preview mode which returns the generated email body without
|
||||
# actually sending the email. Useful for reviewing content in the UI.
|
||||
preview_flag = False
|
||||
try:
|
||||
if request.method == 'POST':
|
||||
preview_flag = str(request.POST.get('preview', '')).lower() in ('1', 'true', 'yes')
|
||||
else:
|
||||
preview_flag = str(request.GET.get('preview', '')).lower() in ('1', 'true', 'yes')
|
||||
except Exception:
|
||||
preview_flag = False
|
||||
|
||||
if preview_flag:
|
||||
# Return plaintext body for preview (opens cleanly in a new tab/window)
|
||||
msg = user.generate_email_details_msg()
|
||||
return HttpResponse(msg, content_type='text/plain')
|
||||
|
||||
email_sent, comment = user.email_details(resend=resend_flag)
|
||||
|
||||
|
||||
logger.debug(f"Email details sent to CID {cid}: sent={email_sent}, comment={comment}")
|
||||
|
||||
return JsonResponse({"sent": email_sent, "comment": str(comment)})
|
||||
|
||||
Reference in New Issue
Block a user