From 4c5c3fed6325ab2f9802482759d8f9b1ff1cbc58 Mon Sep 17 00:00:00 2001 From: kououken Date: Fri, 1 Mar 2019 13:11:41 -0800 Subject: [PATCH] Subject line will omit RT formatting if no number is provided. --- back/backend/views.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/back/backend/views.py b/back/backend/views.py index 347ceaa..2913f82 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -391,13 +391,23 @@ def send_report_to_admin(request, report_pk): cc = request.user.email msg_html = render_to_string('backend/email.html', params) msg_plain = render_to_string('backend/email.txt', params) - message = EmailMultiAlternatives( - "[RT - Request Tracker #{}] {}".format(params['reference_number'], params['title']), - msg_plain, - from_email, - [to_email], - cc=[request.user.email], - ) + message = None + if params['reference_number'] == '': + message = EmailMultiAlternatives( + "{}".format(params['title']), + msg_plain, + from_email, + [to_email], + cc=[request.user.email], + ) + else: + message = EmailMultiAlternatives( + "[RT - Request Tracker #{}] {}".format(params['reference_number'], params['title']), + msg_plain, + from_email, + [to_email], + cc=[request.user.email], + ) message.attach_alternative(msg_html, "text/html") for f in get_files(report_pk): message.attach_file(f)