Skip to content

Commit 3dcbed2

Browse files
[CAPE] New layout for council page (#521)
* [CAPE] New layout for council page * [CAPE] Added survey to bottom of the council page * Move council cards into seperate templates - Big refactor to move all council cards into a unified format * Repurpose navbar to be a long view * Add council name to sidebar * Add different colours to cards * Create info-box template helper * Add text-based summary * Improve descriptions of council areas * Powers card includes more text about multiple layers * Is more explicit about combined authorities. * Fix filter data import * Separate council and whole area pledges in search * Created readable list of filters selected - Clearer when linked in from URL what is happening * Add explainer text for declarations - Add links to councils that have made promises * Add emissions search to search page * Add infobox to emissions data * Shift geography search to use ComparisonLabels - Shifts from using scoring plans - Which are out of date and don't include new councils. * Add IMD profile to council search * Add cite this page card * Tidy up polling intergration * Add navbar custom event * Custom tracking event to see which sidebar items are popular * Tidy up infobox on council-documents * Fix summary card typos * Fix emissions card typos * Stanardise names for cards across menu and files * Fix typos in related-councils section * Move menu config out of views.py * Sort imports in models and views * Switch to vscode extention based linting approach * fix postcode util function * Tidy up scorecard summary * Tidy up format of polling - Make it more basic, can be made pretty later. * Reduce duplication in scorecard * Update altair, vega versions Fixes mobile display bug when width=container * Format navbar scroller - This should rarely be relevant, but if someone shrinks it on a desktop it looks more deliberate. * Improve mobile navbar - mobile navbar will scroll to correct item when page moves - clicks on mobile slightly offset to dodge new bigger navbar * Conditional polling card Polling not displayed if data missing --------- Co-authored-by: Alex Parsons <alex.parsons@mysociety.org>
1 parent 93c2213 commit 3dcbed2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1901
-901
lines changed

.devcontainer/devcontainer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"ms-azuretools.vscode-docker",
1717
"github.vscode-pull-request-github",
1818
"mhutchie.git-graph",
19-
"valentjn.vscode-ltex"
19+
"valentjn.vscode-ltex",
20+
"charliermarsh.ruff",
21+
"ms-python.black-formatter"
2022
]}
2123
}
2224
}

.devcontainer/no-cached-docker-image/devcontainer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"ms-azuretools.vscode-docker",
1818
"github.vscode-pull-request-github",
1919
"mhutchie.git-graph",
20-
"valentjn.vscode-ltex"
20+
"valentjn.vscode-ltex",
21+
"charliermarsh.ruff",
22+
"ms-python.black-formatter"
2123
]}
2224
}
2325
}

.devcontainer/no-initial-populate/devcontainer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"ms-azuretools.vscode-docker",
1717
"github.vscode-pull-request-github",
1818
"mhutchie.git-graph",
19-
"valentjn.vscode-ltex"
19+
"valentjn.vscode-ltex",
20+
"charliermarsh.ruff",
21+
"ms-python.black-formatter"
2022
]}
2123
}
2224
}

.vscode/settings.json

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
2-
"python.linting.pylintEnabled": true,
32
"python.defaultInterpreterPath": "/usr/local/bin/python",
43

54
"editor.formatOnSave": false,
65
"[python]": {
7-
"editor.formatOnSave": true
6+
"editor.formatOnSave": true,
7+
"editor.defaultFormatter": "ms-python.black-formatter"
88
},
99

10-
"python.formatting.provider": "black",
1110
"files.exclude": {
1211
"**/.git": true,
1312
"**/.svn": true,
@@ -19,16 +18,11 @@
1918
},
2019
"files.associations": {
2120
"**/*.html": "html",
22-
"**/templates/**/*.html": "django-html",
21+
"**/templates/**/*.html": "jinja-html",
2322
"**/templates/**/*.md": "jinja-md",
2423
"**/templates/**/*": "django-txt",
2524
"**/requirements{/**,*}.{txt,in}": "pip-requirements"
2625
},
27-
"python.linting.pylintArgs": [
28-
"--max-line-length=88",
29-
"--disable=C0103,E1101,W5101,E1123,E501,E203",
30-
"--load-plugins=pylint_django"
31-
],
3226
"ltex.enabled": ["markdown", "jinja-md"],
3327
"ltex.language": "en-GB",
3428
"[markdown]": {
@@ -37,5 +31,4 @@
3731
"strings": "on",
3832
"other": "on"
3933
}
40-
}
41-
}
34+
}}

caps/helpers/__init__.py

Whitespace-only changes.

caps/helpers/council_navigation.py

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
from typing import NamedTuple
2+
3+
4+
class MenuItem(NamedTuple):
5+
"""
6+
Helper object to track valid council cards
7+
"""
8+
9+
slug: str
10+
title: str
11+
color: str = "green"
12+
desc: str = ""
13+
list_in_summary: bool = True
14+
15+
16+
# new additions here also need to be made to content-navbar.scss
17+
18+
council_menu = [
19+
MenuItem(
20+
slug="summary",
21+
title="Summary",
22+
color="blue",
23+
desc="Overview of CAPE and the information available.",
24+
list_in_summary=False,
25+
),
26+
MenuItem(
27+
slug="new-council",
28+
title="What did this council replace?",
29+
color="red",
30+
desc="Details of councils this authority replaced.",
31+
list_in_summary=False,
32+
),
33+
MenuItem(
34+
slug="old-council",
35+
title="What replaced this council?",
36+
color="red",
37+
desc="Details of councils that replaced this authority.",
38+
list_in_summary=False,
39+
),
40+
MenuItem(
41+
slug="powers",
42+
title="Powers & responsibilities",
43+
color="green",
44+
desc="What the council is responsible for and how it relates to climate change.",
45+
),
46+
MenuItem(
47+
slug="declarations",
48+
title="Declarations & pledges",
49+
color="cyan",
50+
desc="Declarations & pledges the council has made around climate change.",
51+
),
52+
MenuItem(
53+
slug="climate-documents",
54+
title="Climate documents",
55+
desc="Documents, Reports and Plans this council has released related to its climate change plans.",
56+
),
57+
MenuItem(
58+
slug="scorecard",
59+
title="Council Climate Scorecard",
60+
color="green",
61+
desc="How this council's plans scored on CEUK's 2021 Scorecards.",
62+
),
63+
MenuItem(
64+
slug="emissions",
65+
title="Emissions data",
66+
color="blue",
67+
desc="The emissions profile and history for this council.",
68+
),
69+
MenuItem(
70+
slug="emissions-reduction-projects",
71+
title="Emissions reduction projects",
72+
color="blue",
73+
desc="Projects this council has undertaken to reduce emissions.",
74+
),
75+
MenuItem(
76+
slug="local-polling",
77+
title="Local polling",
78+
color="cyan",
79+
desc="MRP Polling of climate change attitudes for this council area.",
80+
),
81+
MenuItem(
82+
slug="related-councils",
83+
title="Related councils",
84+
color="blue",
85+
desc="Lists of councils with similar characteristics to this council.",
86+
),
87+
MenuItem(
88+
slug="other-resources",
89+
title="Other resources",
90+
color="cyan",
91+
desc="Links to other resources and information about this council.",
92+
list_in_summary=False,
93+
),
94+
MenuItem(
95+
slug="download-data",
96+
title="Download our data",
97+
color="red",
98+
desc="How to download the information we hold on UK councils",
99+
list_in_summary=False,
100+
),
101+
MenuItem(
102+
slug="cite",
103+
title="Cite this page",
104+
color="blue",
105+
desc="How to cite or credit infomation on this site",
106+
list_in_summary=False,
107+
),
108+
MenuItem(
109+
slug="improve",
110+
title="Help us improve",
111+
color="green",
112+
desc="Give us feedback on if you found this site useful.",
113+
list_in_summary=False,
114+
),
115+
]

caps/management/commands/import_filter_data.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424

2525

2626
def get_data():
27-
token = settings.PERSONAL_ACCESS_TOKEN
28-
headers = {"Authorization": "token " + token}
29-
r = requests.get(FILTER_DATA_URL, headers=headers)
30-
with open(FILTER_CSV, "wb") as outfile:
31-
outfile.write(r.content)
27+
"""
28+
Download filter_data_url
29+
"""
30+
pd.read_csv(FILTER_DATA_URL).to_csv(FILTER_CSV, index=False)
3231

3332

3433
def import_filters():

0 commit comments

Comments
 (0)