diff --git a/smash/web/views/kit.py b/smash/web/views/kit.py index 7ade6ba5e1ea3093bdaf85ad74d8967030a52b29..aaa91741d4818a97c93d3503d7e8befb5e765997 100644 --- a/smash/web/views/kit.py +++ b/smash/web/views/kit.py @@ -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: