diff --git a/cara/apps/calculator/__init__.py b/cara/apps/calculator/__init__.py
index e0f7a5f4..b91cafb2 100644
--- a/cara/apps/calculator/__init__.py
+++ b/cara/apps/calculator/__init__.py
@@ -58,13 +58,27 @@ class LandingPage(RequestHandler):
self.finish(report)
+class CalculatorForm(RequestHandler):
+ def get(self):
+ import jinja2
+ cara_templates = Path(__file__).parent.parent / "templates"
+ calculator_templates = Path(__file__).parent / "templates"
+ env = jinja2.Environment(
+ loader=jinja2.FileSystemLoader([cara_templates, calculator_templates]),
+ )
+
+ template = env.get_template("calculator.form.html.j2")
+ report = template.render()
+ self.finish(report)
+
+
def make_app(debug=False, prefix='/calculator'):
static_dir = Path(__file__).absolute().parent.parent / 'static'
calculator_static_dir = Path(__file__).absolute().parent / 'static'
urls = [
(r'/?', LandingPage),
(r'/static/(.*)', StaticFileHandler, {'path': static_dir}),
- (prefix + r'/?()', StaticFileHandler, {'path': calculator_static_dir / 'form.html'}),
+ (prefix + r'/?', CalculatorForm),
(prefix + r'/report', ConcentrationModel),
(prefix + r'/baseline-model/result', StaticModel),
(prefix + r'/static/(.*)', StaticFileHandler, {'path': calculator_static_dir}),
diff --git a/cara/apps/calculator/report_generator.py b/cara/apps/calculator/report_generator.py
index 78789faa..93d07d01 100644
--- a/cara/apps/calculator/report_generator.py
+++ b/cara/apps/calculator/report_generator.py
@@ -93,9 +93,10 @@ def build_report(model: models.Model, form: FormData):
context.update(calculate_report_data(model))
- p = Path(__file__).parent / "templates"
+ cara_templates = Path(__file__).parent.parent / "templates"
+ calculator_templates = Path(__file__).parent / "templates"
env = jinja2.Environment(
- loader=jinja2.FileSystemLoader(Path(p)),
+ loader=jinja2.FileSystemLoader([cara_templates, calculator_templates]),
undefined=jinja2.StrictUndefined,
)
env.filters['minutes_to_time'] = minutes_to_time
diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js
index fefa03b4..259cce35 100644
--- a/cara/apps/calculator/static/js/form.js
+++ b/cara/apps/calculator/static/js/form.js
@@ -146,12 +146,10 @@ function show_disclaimer() {
dots.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
- $("#DIALOG_welcome").dialog("option", "height", 185);
} else {
dots.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
- $("#DIALOG_welcome").dialog("option", "height", 600);
}
}
diff --git a/cara/apps/calculator/static/form.html b/cara/apps/calculator/templates/calculator.form.html.j2
similarity index 96%
rename from cara/apps/calculator/static/form.html
rename to cara/apps/calculator/templates/calculator.form.html.j2
index 8a7c765c..df4ccb91 100644
--- a/cara/apps/calculator/static/form.html
+++ b/cara/apps/calculator/templates/calculator.form.html.j2
@@ -1,19 +1,22 @@
-
-
-
-
-
+{% extends "layout.html.j2" %}
-
+{% set CALCULATOR_ACTIVE=1 %}
+
+{% block extra_headers %}
+
+
+{% endblock extra_headers %}
+
+{% block body_scripts %}
-
+
+{% endblock body_scripts %}
-
-
-
-
-
+{% block main %}
+
+
+
Beta v1.0.0
Please send feedback to CARA-dev@cern.ch
CARA Covid Airborne Risk Assessment tool
@@ -185,5 +188,7 @@ You should specify if the event is a one off (give date) or recurrent use of the
-
-
\ No newline at end of file
+
+
+
+{% endblock main %}
\ No newline at end of file
diff --git a/cara/apps/templates/index.html.j2 b/cara/apps/templates/index.html.j2
index 7f7d1f89..e4278a43 100644
--- a/cara/apps/templates/index.html.j2
+++ b/cara/apps/templates/index.html.j2
@@ -1,174 +1,6 @@
-
-
+{% extends "layout.html.j2" %}
+{% set HOME_ACTIVE=1 %}
-
-
-
-
-
-
-
- Welcome | CARA
-
-
-
-
-
-
-
-
-
-
- Skip to main content
-
-
-
-
-
-
-
-
-
-
-
{% block main %}
@@ -182,11 +14,6 @@
CARA: COVID Area Risk Assessment Tools
-
Please try out the CARA COVID calculator here.
Your feedback is most welcome at CARA-dev@cern.ch
@@ -209,148 +36,3 @@
{% endblock main %}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cara/apps/templates/layout.html.j2 b/cara/apps/templates/layout.html.j2
new file mode 100644
index 00000000..61fc4048
--- /dev/null
+++ b/cara/apps/templates/layout.html.j2
@@ -0,0 +1,328 @@
+
+
+
+
+
+
+
+
+
+
+
+ {% block title %}
+ CARA | COVID Airborne Risk Assessment
+ {% endblock title %}
+
+
+
+
+
+
+
+
+ {% block extra_headers %}
+ {% endblock extra_headers %}
+
+
+
+
+
+ Skip to main content
+
+
+
+
+
+
+
+
+
+
+
+ {% block main %}
+ {% endblock main %}
+
+
+
+
+
+
+
+
+
+ {% block body_scripts %}
+ {% endblock body_scripts %}
+
+
+
+
+
\ No newline at end of file