From f19127ad6c9272bfa1125690f18c2d5ee7c44b4c Mon Sep 17 00:00:00 2001
From: Gabriella Azzopardi
Date: Mon, 14 Dec 2020 14:10:13 +0000
Subject: [PATCH] Fixed lunch break bugs
---
cara/apps/calculator/model_generator.py | 5 +++--
cara/apps/calculator/static/js/form.js | 4 ++--
cara/apps/calculator/templates/calculator.form.html.j2 | 2 +-
cara/apps/calculator/templates/report.html.j2 | 4 ++--
cara/tests/apps/calculator/test_model_generator.py | 9 +++++++++
5 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py
index 8a2628f5..b1d97e4b 100644
--- a/cara/apps/calculator/model_generator.py
+++ b/cara/apps/calculator/model_generator.py
@@ -326,11 +326,12 @@ class FormData:
present_intervals.append((time / 60, finish / 60))
break
- if leave_times[-1] <= time:
+ if leave_times[-1] < time:
leave_times.pop()
else:
new_time = leave_times.pop()
- present_intervals.append((time / 60, min(new_time, finish) / 60))
+ if time / 60 != min(new_time, finish) / 60 :
+ present_intervals.append((time / 60, min(new_time, finish) / 60))
is_present = False
time = new_time
diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js
index c4983578..4770ed8d 100644
--- a/cara/apps/calculator/static/js/form.js
+++ b/cara/apps/calculator/static/js/form.js
@@ -292,8 +292,8 @@ function validate_form(form) {
//Validate all lunch breaks
if (submit) {
- $("input[required].lunch").each(function() {
- if (!validateLunchBreak(this)) {
+ $("input[required].start_time[data-lunch-for]").each(function() {
+ if (!validateLunchBreak($(this).data('time-group'))) {
submit = false;
}
});
diff --git a/cara/apps/calculator/templates/calculator.form.html.j2 b/cara/apps/calculator/templates/calculator.form.html.j2
index 274cc63f..7a327f30 100644
--- a/cara/apps/calculator/templates/calculator.form.html.j2
+++ b/cara/apps/calculator/templates/calculator.form.html.j2
@@ -219,7 +219,7 @@
Ventilation data:
- Mechanical ventilation = the HVAC supply of fresh air. Check the flow rates with the concerned technical department.
- - Natural ventilation = the type of window opening. The opening distance is between the fixed frame and movable part when open (commonly used values are window opening between 0.6 and 0.15 m). In case of periodic opening, specify the duration (e.g. for 10 min) and frequency (e.g. every 60 min).
+ - Natural ventilation = the type of window opening. The opening distance is between the fixed frame and movable part when open (commonly used values are window height of 1.6m and window opening between 0.15m and 0.6m). In case of periodic opening, specify the duration (e.g. for 10 min) and frequency (e.g. every 60 min).
- HEPA filtration = the air flow of the device. The following values are based on the different fan velocities of a specific commercial device proposed by the HSE Unit:
- Level 6 (max) = 430 m3/h (noisy)
diff --git a/cara/apps/calculator/templates/report.html.j2 b/cara/apps/calculator/templates/report.html.j2
index fc969752..29f3a28e 100644
--- a/cara/apps/calculator/templates/report.html.j2
+++ b/cara/apps/calculator/templates/report.html.j2
@@ -107,11 +107,11 @@
Gym = For comparison only, all persons doing heavy physical exercise, breathing and not talking.
{% endif %}
- Presence of exposed occupant(s):
+ Exposed occupant(s) activity time:
- Presence of infected occupant(s):
+ Infected occupant(s) activity time:
diff --git a/cara/tests/apps/calculator/test_model_generator.py b/cara/tests/apps/calculator/test_model_generator.py
index 9faedb97..7fe601ce 100644
--- a/cara/tests/apps/calculator/test_model_generator.py
+++ b/cara/tests/apps/calculator/test_model_generator.py
@@ -161,6 +161,15 @@ def test_exposed_present_intervals(baseline_form):
correct = ((9, 10+37/60), (10+52/60, 12.5), (13.5, 15+7/60), (15+22/60, 17.0))
assert baseline_form.exposed_present_interval().present_times == correct
+def test_exposed_present_intervals_starting_with_lunch(baseline_form):
+ baseline_form.coffee_breaks = 0
+ baseline_form.activity_start = baseline_form.lunch_start = 13 * 60
+ baseline_form.activity_finish = 18 * 60
+ baseline_form.lunch_finish = 14 * 60
+ baseline_form.infected_start = 9 * 60
+ baseline_form.infected_finish = 13 * 60
+ correct = ((14.0, 18.0),)
+ assert baseline_form.exposed_present_interval().present_times == correct
def test_coffee_lunch_breaks(baseline_form):
baseline_form.coffee_duration = 30