From 230424edfc3d5b6297bb12e8e36836574709f3fd Mon Sep 17 00:00:00 2001 From: gaazzopa Date: Wed, 9 Dec 2020 18:32:53 +0100 Subject: [PATCH 01/19] Resolved conflict in form.js --- cara/apps/calculator/static/js/form.js | 42 +++---------------- .../templates/calculator.form.html.j2 | 20 ++++----- 2 files changed, 15 insertions(+), 47 deletions(-) diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index fef4d621..862b9f8c 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -1,7 +1,7 @@ /* -------HTML structure------- */ function getChildElement(elem) { // Get the element named in the given element's data-enables attribute. - return $("#" + elem.data("enables")); + return $(elem.data("enables")); } function insertErrorFor(referenceNode, text) { @@ -259,46 +259,14 @@ function show_disclaimer() { } } -$(".has_radio").on('click', function(event){ - click_radio(this.id); +$("[data-has-radio]").on('click', function(event){ + $($(this).data("has-radio")).click(); }); -$(".has_radio").on('change', function(event){ - click_radio(this.id); +$("[data-has-radio]").on('change', function(event){ + $($(this).data("has-radio")).click(); }); -function click_radio(id) { - switch (id) { - case "room_volume": - $("#room_type_volume").click(); - break; - case "floor_area": - case "ceiling_height": - $("#room_type_dimensions").click(); - break; - case "air_supply": - $("#air_type_supply").click(); - break; - case "air_changes": - $("#air_type_changes").click(); - break; - case "window_width": - $("#window_hinged").click(); - break; - case "hepa_amount": - $("#hepa_yes").click(); - break; - case "single_event_date": - $("#event_type_single").click(); - break; - case "recurrent_event_month": - $("#event_type_recurrent").click(); - break; - default: - break; - } -} - /* -------Form validation------- */ function validate_form(form) { var submit = true; diff --git a/cara/apps/calculator/templates/calculator.form.html.j2 b/cara/apps/calculator/templates/calculator.form.html.j2 index cee8be34..e044d7c4 100644 --- a/cara/apps/calculator/templates/calculator.form.html.j2 +++ b/cara/apps/calculator/templates/calculator.form.html.j2 @@ -46,12 +46,12 @@
   -
+
   -
+
         -
+

@@ -62,18 +62,18 @@ Ventilation type:    - +    - +
From 0f981361725ee120e3ad90b30f82ded07d01d1ff Mon Sep 17 00:00:00 2001 From: gaazzopa Date: Wed, 9 Dec 2020 18:34:44 +0100 Subject: [PATCH 03/19] Resolved conflicts in model_generator.py and report.html.j2 --- cara/apps/calculator/model_generator.py | 12 ++++++++---- cara/apps/calculator/templates/report.html.j2 | 12 +++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index 1974e6df..88d0dcb6 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -43,6 +43,8 @@ class FormData: total_people: int ventilation_type: str volume_type: str + windows_duration: float + windows_frequency: float window_height: float window_type: str window_width: float @@ -121,6 +123,8 @@ class FormData: total_people=int(form_data['total_people']), ventilation_type=form_data['ventilation_type'], volume_type=form_data['volume_type'], + windows_duration=float(form_data['windows_duration']), + windows_frequency=float(form_data['windows_frequency']), window_height=float(form_data['window_height']), window_type=form_data['window_type'], window_width=float(form_data['window_width']), @@ -138,7 +142,7 @@ class FormData: # Initializes a ventilation instance as a window if 'natural' is selected, or as a HEPA-filter otherwise if self.ventilation_type == 'natural': if self.windows_open == 'interval': - window_interval = models.PeriodicInterval(120, 10) + window_interval = models.PeriodicInterval(self.windows_frequency*60, self.windows_duration) else: window_interval = always_on @@ -424,7 +428,7 @@ def baseline_raw_form_data(): 'mask_type': 'Type I', 'mask_wearing': 'removed', 'mechanical_ventilation_type': '', - 'model_version': 'v1.1.0', + 'model_version': 'v1.2.0', 'opening_distance': '0.2', 'recurrent_event_month': 'January', 'room_number': '123', @@ -438,7 +442,7 @@ def baseline_raw_form_data(): 'window_type': 'sliding', 'window_width': '2', 'windows_number': '1', - 'windows_open': 'interval' + 'windows_open': 'always' } @@ -449,7 +453,7 @@ MASK_TYPES = {'Type I', 'FFP2'} MASK_WEARING = {'continuous', 'removed'} VENTILATION_TYPES = {'natural', 'mechanical', 'no-ventilation'} VOLUME_TYPES = {'room_volume', 'room_dimensions'} -WINDOWS_OPEN = {'always', 'interval', 'breaks', 'not-applicable'} +WINDOWS_OPEN = {'always', 'interval', 'not-applicable'} WINDOWS_TYPES = {'sliding', 'hinged', 'not-applicable'} diff --git a/cara/apps/calculator/templates/report.html.j2 b/cara/apps/calculator/templates/report.html.j2 index ded74dbb..c640d0f9 100644 --- a/cara/apps/calculator/templates/report.html.j2 +++ b/cara/apps/calculator/templates/report.html.j2 @@ -33,7 +33,7 @@

Ventilation data: