Commit Graph

10192 Commits

Author SHA1 Message Date
Chris Hill-Scott
adad27dadb Lazy load feature from the SQLite database
Rather than querying all the features whenever we look up area(s) let’s
only get them when we need them.

The features are really big blobs of data to pass around, so there’s a
significant performance gain to be had from doing this.
2020-08-12 10:40:27 +01:00
Chris Hill-Scott
3f9e49603d Merge pull request #3544 from alphagov/choose-electoral-ward
Let users select specific electoral wards in a local authority to broadcast to
2020-08-12 08:48:13 +01:00
Chris Hill-Scott
8570901731 Let users select electoral wards of local authorities
If a library has groups, we should show a link instead of selecting the
group directly.

Then we can give the user the choice of selecting the whole of that
group, or specific areas within the group.

For now the only libraries we have with groups are local authorities,
which group electoral wards.
2020-08-11 17:38:15 +01:00
David McDonald
38953d1c28 Merge pull request #3560 from alphagov/turn-redis-back-on
Turn redis back on
2020-08-11 15:40:26 +01:00
David McDonald
2aaca11f8b Turn redis back on 2020-08-11 14:26:12 +01:00
David McDonald
32cc168c23 Merge pull request #3556 from alphagov/turn-redis-off
Turn off redis in all environments for rotation
2020-08-11 14:25:30 +01:00
Chris Hill-Scott
0ce64bcfde Merge pull request #3553 from alphagov/move-broadcast-areas-into-admin
Move broadcast areas into admin
2020-08-11 13:25:21 +01:00
Chris Hill-Scott
ac470ff350 Merge pull request #3559 from alphagov/hidden-email-on-register
Put hidden email field on register from invite page
2020-08-11 13:18:22 +01:00
Toby Lorne
b0ff2d41c5 broadcast-areas: examples are deterministic
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-11 12:04:02 +01:00
Chris Hill-Scott
cf999b5d8e Add inline comment explaining presence of field 2020-08-11 11:26:31 +01:00
Chris Hill-Scott
b0fc1cd271 Make test name more explicit 2020-08-11 11:22:59 +01:00
Toby Lorne
73e68c355b broadcast-areas: include electoral wards
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 18:09:15 +01:00
Toby Lorne
6649d0ac70 broadcast-areas: use area ids in tests
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 18:09:15 +01:00
Chris Hill-Scott
834b0fc3d5 Put hidden email field on register from invite page
Password managers will try to guess what they should save as a username
by looking at the fields on the page where you set up your password.

When registering from an invite the email address (what we use as a
username) is predefined, and only shown on the page as text, not an
input.

This commit also adds a hidden input field for password managers to pick
up.

Adapted from: https://github.com/UKGovernmentBEIS/beis-opss-psd/blob/master/app/views/users/complete_registration.html.erb#L29-L36
2020-08-10 15:59:27 +01:00
Toby Lorne
8c3a8ecd04 broadcast-areas: view test does not assert order
the descriptions are liable to change esp for wards

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 13:04:03 +01:00
Toby Lorne
7a1b80e533 broadcast-areas: sort imports
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:22 +01:00
Toby Lorne
698e9816ec models: use broadcast areas from admin package
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:22 +01:00
Toby Lorne
74b83ffa8b broadcast-areas: vendor areas sqlite3 db
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:22 +01:00
Toby Lorne
488a5440cd broadcast-areas: move broadcast areas into app
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:20 +01:00
Toby Lorne
3243faa9a9 broadcast-areas: import LAs to wards dataset groups
instead of our shonky groupings

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
dde285ef03 broadcast-areas: buffer areas by a larger degree
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
1301ae4bba broadcast-areas: vendor sqlite3 areas
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
4d97ad4399 broadcast-areas: big buffer & try simplify to 99
we want, if possible only 99 points per polygon

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
8b8005966f broadcast-areas: remove unused import
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
0e3158da97 broadcast-areas: only store local authorities once
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
b7e6b94e87 broadcast-areas: and in get_examples
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
b98cf6616c broadcast-areas: remove unused imports
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
01ffc815e7 broadcast-areas: do not use group table
do not need it

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
17af32978f broadcast-areas: use cached_property not a hack
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
8ecbfe5996 broadcast-areas: package works with groups
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
58915ac968 broadcast-areas: plot script works with groups
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
7f4dd0acb5 broadcast-areas: create broadcast areas in groups
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
65bef7bdc3 broadcast-areas: only parse geojson once
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
35a881d950 broadcast-areas: only load geojson when needed
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
0ae8ef650f broadcast-areas: apply buffer to areas
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
22cf63a440 broadcast-areas: simple feature plots show points
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
e21d424f97 broadcast-areas: (dev) add visualisation tool
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
6d5593dc32 broadcast-areas: include simple feature
simple feature is a feature where there are no islands and all polygons
are capped to 125 points

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
7074655b84 broadcast-areas: BroadcastAreaLibraries uses sql
sqlite

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
9a9bf3c270 broadcast-areas: refactor to use repo.py
share functionality between repo used by create script and by package

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
15d4d3c0a1 broadcast-areas: initial repository class
repository to represent the sqlite broadcast areas db

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Toby Lorne
3f54af13b5 broadcast-areas: add a script to build sqlite db
import the raw datasets into a vendored sqlite3 db which can be queried
and versioned with code

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-08-10 12:50:18 +01:00
Leo Hemsted
b3ed21252d ensure you can get broadcast_areas from a list as well as from *args 2020-08-10 12:50:17 +01:00
Chris Hill-Scott
078f1dd8d3 Add broadcast area model, loading from GeoJSON
This commit adds a new model class which can be used by any app to
interact with a broadcast area. A broadcast area is one or more polygons
representing geographical areas.

It also adds some models that make browsing collections of these areas
more straightforward. So the hierarchy looks like:

> **BroadcastAreaLibraries*
> Contains multiple libraries of broadcast area
> > **BroadcastAreaLibrary**
> > A collection of geographic areas, all of the same type, for example
> > counties or electoral wards
> > **BroadcastArea**
> > Contains one or more shapes that make up an area, for example
> > England
> > > **BroadcastArea.polygons[n]**
> > > A single shape, for example the Isle of Wight or Lindisfarne
> > > > **BroadcastArea.polygons[n][o]**
> > > > A single coordinate along a polygons

The classes support iteration, so all the areas in a library can be
looped over, for example if `countries` is an instance of
`BroadcastAreaLibrary` you can do:
```python
for country in countries:
    print(country.name)
```

The `BroadcastAreaLibraries` class also provides some useful methods for
quickly getting the polygons for an area or areas, for example to
render them on a map. So if `libraries` is an instance of
`BroadcastAreaLibraries` you can do:
```python
libraries.get_polygons_for_areas_long_lat('england', 'wales')
```

This will give polygons for the Welsh mainland, the Isle of Wight,
Anglesey, etc.

The models load data from GeoJSON files, which is an open standard for
serialising geographic data. I’ve added a few example files taken from
http://geoportal.statistics.gov.uk to show how it works.
2020-08-10 12:50:17 +01:00
David McDonald
30ed483b7a Turn off redis in all environments for rotation
This is a very short term turn off for while we rotate creds. It will
then be followed immediately by a PR to turn it back on.
2020-08-10 10:25:08 +01:00
Chris Hill-Scott
3573ce1437 Merge pull request #3550 from alphagov/fix-html-escaping-email-subject-preview
Fix HTML being escaped in preview of email subject
2020-08-10 08:59:44 +01:00
Chris Hill-Scott
0e99bede68 Merge pull request #3552 from alphagov/cant-self-approve
Don’t let users self-approve broadcasts
2020-08-06 14:04:07 +01:00
Chris Hill-Scott
479406c02d Don’t let users self-approve broadcasts
At the moment they will get a ‘technical difficulties’ error if they
try.

We probably want to do something around letting people self-approve
broadcasts in trial mode, but for now just telling them they can’t is a
better experience than ‘technical difficulties’ (and will probably be
close to what they should see on a live service as well).
2020-08-05 16:01:21 +01:00
Tom Byers
cd398ab55c Merge pull request #3543 from alphagov/remove-code-supporting-old-permissions-form_fields
Revert support for old user permissions params
2020-08-05 15:51:28 +01:00
David McDonald
8b44919551 Merge pull request #3548 from alphagov/pyup-scheduled-update-2020-08-03
Scheduled weekly dependency update for week 31
2020-08-05 10:30:19 +01:00