Skip to content
Snippets Groups Projects
Commit 28d8b239 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

formatting of the email improved

parent d6213112
No related branches found
No related tags found
1 merge request!47Resolve "Email to technician"
Pipeline #
......@@ -74,20 +74,30 @@ def kit_requests_send_mail(request, start_date, end_date=None):
end_date_str = data["end_date"].strftime('%Y-%m-%d')
title = "Kits required between " + data["start_date"].strftime('%Y-%m-%d') + " and " + end_date_str
cell_style = "padding: 8px; line-height: 1.42857143; vertical-align: top; " \
"font-size: 14px; font-family: 'Source Sans Pro','Helvetica Neue',Helvetica,Arial,sans-serif;"
email_body = "<h1>" + title + "</h1>"
email_body += "<table><thead><tr><th>Date</th><th>Kits</th><th>Location</th><th>Person responsible</th></tr></thead>"
email_body += '<table style="border: 1px solid #f4f4f4;border-spacing: 0;border-collapse: collapse;">' \
'<thead><tr><th>Date</th><th>Kits</th><th>Location</th><th>Person responsible</th></tr></thead>'
email_body += "<tbody>"
even = True
for appointment in data["appointments"]:
email_body += "<tr>"
email_body += "<td>" + appointment.datetime_when.strftime('%Y-%m-%d %H:%M') + "</td>"
email_body += "<td>"
row_style = ""
even = not even
if even:
row_style = ' background-color: #f9f9f9;'
email_body += "<tr style='" + row_style + "'>"
email_body += "<td style='" + cell_style + "'>" + appointment.datetime_when.strftime('%Y-%m-%d %H:%M') + "</td>"
email_body += "<td style='" + cell_style + "'>"
for type in appointment.appointment_types.all():
for item in type.required_equipment.all():
if item.disposable:
email_body += item.name + ", "
email_body += "</td>"
email_body += "<td>" + str(appointment.location) + "</td>"
email_body += "<td>" + str(appointment.worker_assigned) + "</td>"
email_body += "<td style='" + cell_style + "'>" + str(appointment.location) + "</td>"
email_body += "<td style='" + cell_style + "'>" + str(appointment.worker_assigned) + "</td>"
email_body += "</tr>"
email_body += "</tbody></table>"
recipients = ConfigurationItem.objects.get(type=KIT_RECIPIENT_EMAIL_CONFIGURATION_TYPE).value
......@@ -96,6 +106,7 @@ def kit_requests_send_mail(request, start_date, end_date=None):
if sender is not None:
cc_recipients.append(sender)
try:
print email_body
EmailSender().send_email(title, email_body, recipients, cc_recipients)
messages.add_message(request, messages.SUCCESS, 'Mail sent')
except:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment