diff --git a/smash/web/views/virus_mail.py b/smash/web/views/virus_mail.py index 2cf38c38e3602446fba53e15efdd19efe6aa6639..5901f419daea7a81c7607dd119abf4d9b7a3f384 100644 --- a/smash/web/views/virus_mail.py +++ b/smash/web/views/virus_mail.py @@ -55,18 +55,49 @@ def get_subject_statistics(): def create_statistic_email_content(data, title): - email_body = "<h1>" + title + "</h1>" + email_body = u"<h1>" + title + "</h1>" + + email_body += u'<b>Date: {}</b>'.format(datetime.datetime.now().strftime('%d.%m.%Y')) + "</br></br>" + + email_body += u"In the past 24 hours " + str(data["total"]) + " donors were tested</br></br>" + + email_body += """ + <table style="border: 1px solid black; border-collapse: collapse;"> + <tr style="border: 1px solid black;"> + <th style="border: 1px solid black;">SARS-COV2 Virus</th> + <th style="border: 1px solid black;">Number of Donors</th> + </tr> + """ - email_body += "In the past 24 hours " + str(data["total"]) + " donors were tested</br></br>" for status in data: if status != "total": - email_body += str(data[status]) + ' number of donors were tested ' + status + "</br>" + email_body += """ + <tr style="border: 1px solid black;"> + <td style="border: 1px solid black;">{}</td> + <td style="border: 1px solid black; text-align: right;">{}</td> + </tr> + """.format(status, data[status]) + + email_body += """ + <tr style="border: 1px solid black;"> + <td style="border: 1px solid black;">{}</td> + <td style="border: 1px solid black; text-align: right;">{}</td> + </tr> + """.format('Total', data["total"]) + + email_body += "</table>" + + #SARS-COV2 Virus  | Number of Donors + #Inconclusive  | 5 + #Positive  | 15 + #Negative  | 45 + #Total  | 65 return email_body def send_mail(data): - title = "Virus test statistics" + title = "SARS-COV2 Virus RT-PCR Assay Statistics" email_body = create_statistic_email_content(data, title) recipients = []