From 8dcd913ebe49dff8f30347a01d8bab55f5b695de Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Thu, 8 Jul 2021 17:31:27 +0200 Subject: [PATCH] Added error message for the case when the CERN Covid Level is not specified --- cara/apps/calculator/report_generator.py | 55 ++----------------- .../cern/templates/calculator.report.html.j2 | 27 +++++++-- 2 files changed, 29 insertions(+), 53 deletions(-) diff --git a/cara/apps/calculator/report_generator.py b/cara/apps/calculator/report_generator.py index 6f377157..04cd63aa 100644 --- a/cara/apps/calculator/report_generator.py +++ b/cara/apps/calculator/report_generator.py @@ -276,29 +276,6 @@ def comparison_report(scenarios: typing.Dict[str, models.ExposureModel]): 'stats': statistics, } -def get_level_warning(scale_warning, incidence_rate, onsite_access, threshold) -> dict: - if scale_warning == 'Green - 1': - scale_level = { - 'display_png': '/static/images/warning_scale/level1.png', - 'display_text': f'Note: the current CERN COVID Scale is Green - 1, which means the incidence rate in the local community is {incidence_rate}. Align your risk assessment with the guidance and instructions provided by the HSE Unit.' - } - elif scale_warning == 'Yellow - 2': - scale_level = { - 'display_png': '/static/images/warning_scale/level2.png', - 'display_text': f'Note: the current CERN COVID Scale is Yellow - 2, which means the incidence rate in the local community is {incidence_rate}. There is a reduced chance that asymptomatic or pre-symptomatic infected individuals circulate within the CERN site which, during this stage, corresponds to an average daily on-site access {onsite_access}. See with your supervisor if this scenario is acceptable.' - } - elif scale_warning == 'Orange - 3': - scale_level = { - 'display_png': '/static/images/warning_scale/level3.png', - 'display_text': f'Warning: the current CERN COVID Scale is Orange - 3, which means the incidence rate in the local community is {incidence_rate}. There is a slight chance that asymptomatic or pre-symptomatic infected individuals circulate within the CERN site which, during this stage, corresponds to an average daily on-site access {onsite_access}. See with your supervisor if any additional measures can be applied (ALARA).' - } - elif scale_warning == 'Red - 4': - scale_level = { - 'display_png': '/static/images/warning_scale/level4.png', - 'display_text': f'Warning: the current CERN COVID Scale is Red - 4, which means the incidence rate in the local community is {incidence_rate}. There is a strong chance that asymptomatic or pre-symptomatic infected individuals circulate within the CERN site which, during this stage, corresponds to an average daily on-site access {onsite_access}. Please reduce the value below the threshold of {threshold}.' - } - return scale_level - @dataclasses.dataclass class ReportGenerator: @@ -314,31 +291,6 @@ class ReportGenerator: now = datetime.utcnow().astimezone() time = now.strftime("%Y-%m-%d %H:%M:%S UTC") - #Specify here the CERN COVID Scale, as well as its incidence_rate, on-site access and threshold - ''' - Green - 1: - covid_scale = 'Green - 1' - incidence_rate = 'considered negligible' - onsite_access = '' - threshold = '' - Yellow - 2: - covid_scale = 'Yellow - 2' - incidence_rate = 'lower than 25 new cases per 100 000 inhabitants' - onsite_access = 'of about 8000' - threshold = NA - Orange - 3: - covid_scale = 'Orange - 3' - incidence_rate = 'somewhere in between 25 and 100 new cases per 100 000 inhabitants' - onsite_access = 'of about 5000' - threshold = '' - Red - 4: - covid_scale = 'Red - 4' - incidence_rate = 'higher or equal to 100 new cases per 100 000 inhabitants' - onsite_access = 'lower than 4000' - threshold = '5%' - ''' - scale_warning = get_level_warning(scale_warning = 'Red - 4', incidence_rate = 'higher or equal to 100 new cases per 100 000 inhabitants', onsite_access = 'lower than 4000', threshold = '') - context = { 'model': model, 'form': form, @@ -350,7 +302,12 @@ class ReportGenerator: context['alternative_scenarios'] = comparison_report(alternative_scenarios) context['qr_code'] = generate_qr_code(base_url, self.calculator_prefix, form) context['calculator_prefix'] = self.calculator_prefix - context['scale_warning'] = scale_warning + context['scale_warning'] = { + 'level': '', + 'incidence_rate': 'somewhere in between 25 and 100 new cases per 100 000 inhabitants', + 'onsite_access': 'of about 5000', + 'threshold' : '' + } return context def _template_environment(self) -> jinja2.Environment: diff --git a/cara/apps/calculator/themes/cern/templates/calculator.report.html.j2 b/cara/apps/calculator/themes/cern/templates/calculator.report.html.j2 index 3c088547..58c5f7a4 100644 --- a/cara/apps/calculator/themes/cern/templates/calculator.report.html.j2 +++ b/cara/apps/calculator/themes/cern/templates/calculator.report.html.j2 @@ -27,13 +27,32 @@ {{ super() }} {% if (prob_inf > 5) %} - -
- +
+ {% if scale_warning.level == "Green - 1" %} + + {% elif scale_warning.level == "Yellow - 2" %} + + + {% elif scale_warning.level == "Orange - 3" %} + + + {% elif scale_warning.level == "Red - 4" %} + + + {% else %} +

Note: The CERN COVID Level is not specified.

+ {% endif %}
+ {% endif %} {% if ((prob_inf > 15) or (expected_new_cases >= 1)) %}