Rename the report version to calculator_version, and report a timezone with the date in the report (UTC).
This commit is contained in:
parent
2c12797962
commit
f530a52886
5 changed files with 18 additions and 10 deletions
|
|
@ -4,7 +4,6 @@ import os
|
|||
from pathlib import Path
|
||||
|
||||
import jinja2
|
||||
import mistune
|
||||
from tornado.web import Application, RequestHandler, StaticFileHandler
|
||||
|
||||
from . import model_generator
|
||||
|
|
@ -12,6 +11,16 @@ from .report_generator import build_report
|
|||
from .user import AuthenticatedUser, AnonymousUser
|
||||
|
||||
|
||||
# The calculator version is based on a combination of the model version and the
|
||||
# semantic version of the calculator itself. The version uses the terms
|
||||
# "{MAJOR}.{MINOR}.{PATCH}" to describe the 3 distinct numbers constituing a version.
|
||||
# Effectively, if the model increases its MAJOR version then so too should this
|
||||
# calculator version. If the calculator needs to make breaking changes (e.g. change
|
||||
# form attributes) then it can also increase its MAJOR version without needing to
|
||||
# increase the overall CARA version (found at ``cara.__version__``).
|
||||
__version__ = "1.5.0"
|
||||
|
||||
|
||||
class BaseRequestHandler(RequestHandler):
|
||||
async def prepare(self):
|
||||
"""Called at the beginning of a request before `get`/`post`/etc."""
|
||||
|
|
@ -81,6 +90,7 @@ class CalculatorForm(BaseRequestHandler):
|
|||
report = template.render(
|
||||
user=self.current_user,
|
||||
xsrf_form_html=self.xsrf_form_html(),
|
||||
calculator_version=__version__,
|
||||
)
|
||||
self.finish(report)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import numpy as np
|
|||
|
||||
from cara import models
|
||||
from cara import data
|
||||
from .. import calculator
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
@ -551,7 +552,7 @@ def baseline_raw_form_data():
|
|||
'mask_type': 'Type I',
|
||||
'mask_wearing_option': 'mask_off',
|
||||
'mechanical_ventilation_type': '',
|
||||
'model_version': 'v1.2.0',
|
||||
'model_version': calculator.__version__,
|
||||
'opening_distance': '0.2',
|
||||
'event_month': 'January',
|
||||
'room_number': '123',
|
||||
|
|
|
|||
|
|
@ -260,13 +260,11 @@ def comparison_report(scenarios: typing.Dict[str, models.ExposureModel]):
|
|||
|
||||
|
||||
def build_report(base_url: str, model: models.ExposureModel, form: FormData):
|
||||
now = datetime.now()
|
||||
time = now.strftime("%d/%m/%Y %H:%M:%S")
|
||||
request = {"the": "form", "request": "data"}
|
||||
now = datetime.utcnow().astimezone()
|
||||
time = now.strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||
|
||||
context = {
|
||||
'model': model,
|
||||
'request': request,
|
||||
'form': form,
|
||||
'creation_date': time,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "layout.html.j2" %}
|
||||
|
||||
{% set MODEL_VERSION="v1.5.1" %}
|
||||
{% set DEBUG=False %}
|
||||
{% set active_page="calculator/" %}
|
||||
|
||||
|
|
@ -20,7 +19,7 @@
|
|||
<div class="text-component text-component-page clearfix"></div>
|
||||
<div style="height: 8em; display: block;"></div>
|
||||
|
||||
{{ MODEL_VERSION }} <span style="float:right; font-weight:bold">Please send feedback to <a href="mailto:CARA-dev@cern.ch">CARA-dev@cern.ch</a></span>
|
||||
v{{ calculator_version }} <span style="float:right; font-weight:bold">Please send feedback to <a href="mailto:CARA-dev@cern.ch">CARA-dev@cern.ch</a></span>
|
||||
<div>
|
||||
<img src="/static/images/cara_logo.png" style="height:175px; width:100px; display:inline-block; vertical-align:middle; object-fit:cover;">
|
||||
<h1 style="display:inline-block; vertical-align:middle;"><b>CARA - </b> COVID Airborne Risk Assessment calculator</h1>
|
||||
|
|
@ -33,7 +32,7 @@
|
|||
{% endif %}
|
||||
{{ xsrf_form_html }}
|
||||
|
||||
<input type="hidden" name="model_version" value={{ MODEL_VERSION }}>
|
||||
<input type="hidden" name="model_version" value="{{ calculator_version }}">
|
||||
|
||||
<div style="width: 33%; float:left;">
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
<h1 style="display:inline-block; vertical-align:middle; margin-left:-30pt;">Report</h1>
|
||||
</div>
|
||||
|
||||
<p class=subtitle> Created {{ creation_date }} using model version {{ form.model_version }}</p><br>
|
||||
<p class=subtitle> Created {{ creation_date }} using model version v{{ form.model_version }}</p><br>
|
||||
|
||||
<p><strong>Applicable rules: <br>
|
||||
Please ensure that this scenario conforms to current <a href="https://hse.cern/covid-19-information"> CERN HSE rules</a> (minimum ventilation requirements, mask wearing and the maximum number of people permitted in a space).</strong> <br>
|
||||
|
|
|
|||
Loading…
Reference in a new issue