added placeholder for activity types and fetched this data directly in form calculator
This commit is contained in:
parent
a843c47b83
commit
6a69f91c90
3 changed files with 40 additions and 19 deletions
|
|
@ -294,6 +294,11 @@ class LandingPage(BaseRequestHandler):
|
|||
|
||||
class CalculatorForm(BaseRequestHandler):
|
||||
def get(self):
|
||||
data_registry: DataRegistry = self.settings["data_registry"]
|
||||
data_service: typing.Optional[DataService] = self.settings.get("data_service", None)
|
||||
if data_service:
|
||||
data_service.update_registry(data_registry)
|
||||
|
||||
template_environment = self.settings["template_environment"]
|
||||
template = template_environment.get_template(
|
||||
"calculator.form.html.j2")
|
||||
|
|
@ -304,6 +309,7 @@ class CalculatorForm(BaseRequestHandler):
|
|||
get_calculator_url = template.globals["get_calculator_url"],
|
||||
calculator_version=__version__,
|
||||
text_blocks=template_environment.globals["common_text"],
|
||||
data_registry=data_registry.to_dict(),
|
||||
)
|
||||
self.finish(report)
|
||||
|
||||
|
|
|
|||
|
|
@ -506,18 +506,12 @@
|
|||
<div class="col-sm-4"><label class="col-form-label">Activity type:</label></div>
|
||||
<div class="col-sm-6">
|
||||
<select id="activity_type" name="activity_type" class="form-control">
|
||||
<option value="office">Office</option>
|
||||
<option value="smallmeeting">Small meeting (<10 occ.)</option>
|
||||
<option value="largemeeting">Large meeting (>=10 occ.)</option>
|
||||
<option value="callcentre">Call Centre</option>
|
||||
<option value="controlroom-day">Control Room - Day shift</option>
|
||||
<option value="controlroom-night">Control Room - Night shift</option>
|
||||
<option value="library">Library</option>
|
||||
<option value="lab">Laboratory</option>
|
||||
<option value="workshop">Workshop</option>
|
||||
<option value="training">Conference/Training (speaker infected)</option>
|
||||
<option value="training_attendee">Conference/Training (attendee infected)</option>
|
||||
<option value="gym">Gym</option>
|
||||
{% for activity_type_key, activity_type_value in data_registry.population_scenario_activity.items() %}
|
||||
{% if activity_type_key not in ["precise", "household-day", "household-night", "primary-school",
|
||||
"secondary-school", "university", "restaurant"] %}
|
||||
<option value="{{ activity_type_key }}">{{ activity_type_value['placeholder'] }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -389,63 +389,84 @@ class DataRegistry:
|
|||
}
|
||||
monte_carlo_sample_size = 250000
|
||||
population_scenario_activity = {
|
||||
"office": {"activity": "Seated", "expiration": {"Speaking": 1, "Breathing": 2}},
|
||||
"office": {"placeholder": "Office", "activity": "Seated", "expiration": {"Speaking": 1, "Breathing": 2}},
|
||||
"smallmeeting": {
|
||||
"placeholder": "Small meeting (<10 occ.)",
|
||||
"activity": "Seated",
|
||||
"expiration": {"Speaking": 1},
|
||||
},
|
||||
"largemeeting": {
|
||||
"placeholder": "Large meeting (>= 10 occ.)",
|
||||
"activity": "Standing",
|
||||
"expiration": {"Speaking": 1, "Breathing": 2},
|
||||
},
|
||||
"callcenter": {"activity": "Seated", "expiration": {"Speaking": 1}},
|
||||
"callcenter": {"placeholder": "Call Center", "activity": "Seated", "expiration": {"Speaking": 1}},
|
||||
"controlroom-day": {
|
||||
"placeholder": "Control Room - Day shift",
|
||||
"activity": "Seated",
|
||||
"expiration": {"Speaking": 1, "Breathing": 1},
|
||||
},
|
||||
"controlroom-night": {
|
||||
"placeholder": "Control Room - Night shift",
|
||||
"activity": "Seated",
|
||||
"expiration": {"Speaking": 1, "Breathing": 9},
|
||||
},
|
||||
"library": {"activity": "Seated", "expiration": {"Breathing": 1}},
|
||||
"library": {"placeholder": "Library", "activity": "Seated", "expiration": {"Breathing": 1}},
|
||||
"lab": {
|
||||
"placeholder": "Lab",
|
||||
"activity": "Light activity",
|
||||
"expiration": {"Speaking": 1, "Breathing": 1},
|
||||
},
|
||||
"workshop": {
|
||||
"placeholder": "Workshop",
|
||||
"activity": "Moderate activity",
|
||||
"expiration": {"Speaking": 1, "Breathing": 1},
|
||||
},
|
||||
"training": {"activity": "Standing", "expiration": {"Speaking": 1}},
|
||||
"training_attendee": {"activity": "Seated", "expiration": {"Breathing": 1}},
|
||||
"gym": {"activity": "Heavy exercise", "expiration": {"Breathing": 1}},
|
||||
"training": {"placeholder": "Conference/Training (speaker infected)", "activity": "Standing", "expiration": {"Speaking": 1}},
|
||||
"training_attendee": {"placeholder": "Conference/Training (attendee infected)", "activity": "Seated", "expiration": {"Breathing": 1}},
|
||||
"gym": {"placeholder": "Gym", "activity": "Heavy exercise", "expiration": {"Breathing": 1}},
|
||||
"household-day": {
|
||||
"placeholder": "Household (day time)",
|
||||
"activity": "Light activity",
|
||||
"expiration": {"Breathing": 5, "Speaking": 5},
|
||||
},
|
||||
"household-night": {
|
||||
"placeholder": "Household (evening and night time)",
|
||||
"activity": "Seated",
|
||||
"expiration": {"Breathing": 7, "Speaking": 3},
|
||||
},
|
||||
"primary-school": {
|
||||
"placeholder": "Primary school",
|
||||
"activity": "Light activity",
|
||||
"expiration": {"Breathing": 5, "Speaking": 5},
|
||||
},
|
||||
"secondary-school": {
|
||||
"placeholder": "Primary school",
|
||||
"activity": "Light activity",
|
||||
"expiration": {"Breathing": 7, "Speaking": 3},
|
||||
},
|
||||
"university": {
|
||||
"placeholder": "University",
|
||||
"activity": "Seated",
|
||||
"expiration": {"Breathing": 9, "Speaking": 1},
|
||||
},
|
||||
"restaurant": {
|
||||
"placeholder": "Restaurant",
|
||||
"activity": "Seated",
|
||||
"expiration": {"Breathing": 1, "Speaking": 9},
|
||||
},
|
||||
"precise": {"activity": "", "expiration": {}},
|
||||
"precise": {"placeholder": "Precise", "activity": "", "expiration": {}},
|
||||
}
|
||||
|
||||
def to_dict(self):
|
||||
# Filter out methods, special attributes, and non-serializable objects
|
||||
data_dict = {
|
||||
key: value
|
||||
for key, value in self.__class__.__dict__.items()
|
||||
if not key.startswith("__") and not callable(value) and not isinstance(value, (type, classmethod, staticmethod))
|
||||
}
|
||||
return data_dict
|
||||
|
||||
def update(self, data, version=None):
|
||||
"""Update local cache with data provided as argument."""
|
||||
for attr_name, value in data.items():
|
||||
|
|
|
|||
Loading…
Reference in a new issue