From d0c331a3106172d46a8f973a89100b63470a750a Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 12 Dec 2023 16:31:52 +0000 Subject: [PATCH] WIP using new area page for area page --- hub/templates/hub/area/_json_data.html | 49 +++ hub/templates/hub/new_area_page.html | 406 ++++++++----------------- hub/tests/test_views.py | 10 +- hub/views/area.py | 13 +- 4 files changed, 190 insertions(+), 288 deletions(-) create mode 100644 hub/templates/hub/area/_json_data.html diff --git a/hub/templates/hub/area/_json_data.html b/hub/templates/hub/area/_json_data.html new file mode 100644 index 000000000..fca0948d2 --- /dev/null +++ b/hub/templates/hub/area/_json_data.html @@ -0,0 +1,49 @@ +{% load humanize %} +{% if dataset.name.lower == "results of last election" %} + + + + + + + + + {% for data in dataset.data.value.results|dictsortreversed:"votes" %} + {% if data.votes != 0 %} + + + + + {% endif %} + {% endfor %} + +
PartyVotes
{{ data.party }}{{ data.votes }}
+{% elif dataset.name.lower == "popular petitions" %} + + + + + + + + + {% for petition in dataset.data.value %} + + + + + {% endfor %} + +
PetitionSignatures
{{ petition.action }}{{ petition.signatures }}
+{% elif dataset.subcategory == "groups" %} +
{{ dataset.label }}
+ +{% endif %} diff --git a/hub/templates/hub/new_area_page.html b/hub/templates/hub/new_area_page.html index 72edf30b0..d13d0ce1d 100644 --- a/hub/templates/hub/new_area_page.html +++ b/hub/templates/hub/new_area_page.html @@ -226,336 +226,190 @@

Date elected

+ {% if categories.opinion %}

Public opinion

- - - - -
+ {% endif %} + {% if categories.place %}

Place

- - -
-
-

Child poverty

-
- -
-
-
-

24.4%

-

28.2% national average

-
- -
- -
+ {% for dataset in categories.place %} + {% if dataset.is_range and dataset.data|length > 9 %} +
+ {% elif dataset.is_range or dataset.data_type == "json" %} +
+ {% else %} +
+ {% endif %}
-

Socio-economic status

+

{{ dataset.label }} {{ dataset.data_type }} {{ dataset.data|length }}

+ {% if dataset.data_type == "json" %} + {% include 'hub/area/_json_data.html' with dataset=dataset %} + {% elif dataset.data_type == "text" %} +

{{ dataset.data.value|safe }}

+ {% elif dataset.is_range %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + {% for row in dataset.data %} + + + + + + {% endfor %} +
StatusThis areaUK average
Full-time students29.3%7.4%
Higher managerial, administrative and professional occupations10.5%12.9%
Intermediate occupations8.0%11.5%
Lower managerial, administrative and professional occupations15.3%19.9%
Lower supervisory and technical occupations3.3%5.5%
Never worked / long-term unemployed10.9%8.5%
Routine occupations9.4%12.2%
Semi-routine occupations7.8%11.5%
Small employers and own account workers5.5%10.6%
This areaUK Average
+ {{ row.label|html_format_dataset_name|safe }} + {{ row.value|floatformat }}%{{ row.average|floatformat }}%
+ {% else %} +

{{ dataset.data.value|floatformat }}%

+

{{dataset.data.average|floatformat }}% national average

+ {% endif %}
+ {% endfor %} +
- + +
+ {% endif %} - -
-
-

Index of Multiple Deprivation

-
- -
-
-
-

2

-

Very deprived

-
- -
+
+

Movement

+
-
+ {% for dataset in categories.movement %} + {% if dataset.is_range and dataset.data|length > 9 %} +
+ {% elif dataset.is_range or dataset.data_type == "json" %} +
+ {% else %} +
+ {% endif %}
-

Country of the UK

+

{{ dataset.label }}

-

England

+ {% if dataset.data_type == "json" %} + {% include 'hub/area/_json_data.html' with dataset=dataset %} + {% elif dataset.data_type == "percentage" %} +

{{ dataset.data.value|floatformat }}%

+

{{dataset.data.average|floatformat }}% national average

+ {% elif dataset.data_type == "integer" %} +

{{ dataset.data.value }}

+

{{dataset.data.average|floatformat }} national average

+ {% elif dataset.is_range %} + + + + + + + + + + {% for row in dataset.data %} + + + + + + {% endfor %} + +
This areaUK Average
+ {{ row.label|html_format_dataset_name|safe }} + {{ row.value|floatformat }}%{{ row.average|floatformat }}%
+ {% else %} +

{{ dataset.data.value|safe }}

+ {% endif %}
- -
- -
- -
-

Movement

-
- + {% endfor %}