Commit Graph

11834 Commits

Author SHA1 Message Date
karlchillmaid
c406f64bd3 Merge pull request #4008 from alphagov/update-service-name-advice
Update service name advice
2021-09-01 12:32:33 +01:00
karlchillmaid
9f302050c4 Add 'initialism' 2021-09-01 11:31:48 +01:00
karlchillmaid
e0617004f5 Add 'initialism' 2021-09-01 11:30:01 +01:00
karlchillmaid
ef112df5eb Merge pull request #4005 from alphagov/update-security-page
Update Security page content
2021-08-27 14:30:46 +01:00
karlchillmaid
fd5a1d980b Fix link text, add security classification info 2021-08-27 13:58:10 +01:00
Ben Thorner
6c4340c5eb Merge pull request #4004 from alphagov/areas-refactor-178986763
Prepare to migrate to new format for "areas"
2021-08-27 11:49:07 +01:00
Ben Thorner
9667433b7e Add temporary command to migrate data for "areas"
This will be run with a CSV of all broadcast messages. Since very
few users are creating or updating broadcasts, it's highly unlikely
we'll encounter a race condition during the update.
2021-08-26 13:08:05 +01:00
Ben Thorner
39a1212508 Switch existing command to standard approach
This is the suggested approach in the documentation [1] and using
it makes it clearer what's going on and to add other commands with
arguments, which we'll do in the next commit.

[1]: https://flask.palletsprojects.com/en/2.0.x/cli/#custom-commands
2021-08-26 12:49:55 +01:00
Ben Thorner
7dbe3afa19 Include area names in data we send to API
These will be used as a fallback for display in gov.uk/alerts. It
also helps to have them in the DB to aid in quickly identifying
where an alert was sent, which is hard from the IDs.

We will look at backfilling names for past alerts in future work.
2021-08-26 12:49:54 +01:00
Ben Thorner
ae7f23d4cb DRY-up sending area updates to the API 2021-08-26 12:49:53 +01:00
Ben Thorner
73f31ef2fd DRY-up getting and setting area_ids
Previously we just held the new area_ids in memory. Setting them
on the object means we can reuse its functionality to get polygons
and also avoids confusion if in future we try to continue using
the object after calling "add_areas" or "remove_areas".
2021-08-26 12:49:52 +01:00
Ben Thorner
11cbee5843 Switch to using temporary "areas_2" API field
Depends on: https://github.com/alphagov/notifications-api/pull/3312

This is part of a multi-stage migration where we want to repurpose
the "areas" field in the existing API to something like "areas_2".
2021-08-26 11:01:56 +01:00
Ben Thorner
de9d1f991b Stop saying "areas" when we mean "area_ids"
"areas" normally means an instance of BroadcastArea or similar, so
we should be more accurate to avoid confusion.
2021-08-26 11:01:35 +01:00
Ben Thorner
bdf0fdbd5f Merge pull request #4002 from alphagov/refactor-area-methods-178986763
Initial refactors to support area aggregation
2021-08-24 14:25:54 +01:00
Chris Hill-Scott
5ba8387c6d Bump utils to 44.5.0
Brings in a new `intersects_with()` method of `Polygons` which will come
in handy.
2021-08-23 16:57:15 +01:00
Ben Thorner
427ac0c8c1 Fix misleading name for overlap method
Resolves: https://github.com/alphagov/notifications-admin/pull/3980#discussion_r692919874

Previously it was unclear what kinds of areas this method returned,
and whether there would be any duplicates (due to the hierarchy of
areas we work with). This clarifies that.

In addition, the areas returned may not overlap with the custom one
[1], so we should reword to avoid falsely implying that. We could do
the overlap check as part of the method as an alternative, but that
would create extra work when calculating the ratio of intersection.
We could always add "overlapping areas" as a complementary method to
this one in future.

[1]: https://github.com/alphagov/notifications-admin/pull/3980#discussion_r692919874
2021-08-23 16:56:47 +01:00
Ben Thorner
d2784d0d8a Rename "parents" methods to "ancestors"
Resolves: https://github.com/alphagov/notifications-admin/pull/3980#discussion_r694002952

A grandparent is not a parent, so the return value of these methods
were misleading. This makes it clearer.
2021-08-23 16:50:18 +01:00
Ben Thorner
1923c5edb1 Remove redundant 'filter' and return value
'None' is the implicit return value. Since the filter was operating
on a yield that never yield 'None', it was redundant.
2021-08-23 16:35:38 +01:00
Chris Hill-Scott
a50b77d52c Merge pull request #4000 from alphagov/email-validate-password-reset
Update `email_access_validated_at` as soon as a you click a fresh link
2021-08-19 15:40:17 +01:00
Chris Hill-Scott
5c1920fc20 Remove old method of updating email_access_validated_at
Previously we were passing a flag to the API which handled this. Now
we are doing it at the time of clicking the link, not at the time of
storing the new password. We don’t need to update the timestamp twice,
so this commit removes the code which tells the API to do it.
2021-08-19 11:14:47 +01:00
Chris Hill-Scott
8355abeaf2 Update email_access_validated_at on invite
Accepting an invite means that you’ve just clicked a link in your email
inbox. This shows that you have access to your email.

We can make a record of this, thereby extending the time before we ask
you to revalidate your email address.
2021-08-19 11:14:47 +01:00
Chris Hill-Scott
cb59413581 Update email_access_validated_at on link click
When someone uses a fresh password reset link they have proved that they
have access to their inbox.

At the moment, when revalidating a user’s email address we wait until
after they’ve put in the 2FA code before updating the timestamp which
records when they last validated their email address[1].

We can’t think of a good reason that we need the extra assurance of a
valid 2FA code to assert that the user has access to their email –
they’ve done that just by clicking the link. When the user clicks the
link we already update their failed login count before they 2fa. Think
it makes sense to handle `email_access_validated_at` then too.

As a bonus, the functional tests never go as far as getting a 2FA code
after a password reset[2], so the functional test user never gets its
timestamp updated. This causes the functional tests start failing after
90 days. By moving the update to this point we ensure that the
functional tests will keep passing indefinitely.

1. This code in the API (91542ad33e/app/dao/users_dao.py (L131))
   which is called by this code in the admin app (9ba37249a4/app/utils/login.py (L26))
2. 5837eb01dc/tests/functional/preview_and_dev/test_email_auth.py (L43-L46)
2021-08-19 11:14:47 +01:00
Chris Hill-Scott
ff12ba689d Merge pull request #3993 from alphagov/4-hours-expiry-test-channels
Expire test and operator alerts after 4 hours
2021-08-18 10:12:26 +01:00
Leo Hemsted
9ba37249a4 Merge pull request #3975 from alphagov/redirect
follow sign_in redirect even if you're already signed in
2021-08-17 14:58:12 +01:00
Leo Hemsted
71d3aa13d7 follow sign_in redirect even if you're already signed in 2021-08-17 14:44:09 +01:00
Chris Hill-Scott
4ead26c806 Merge pull request #3998 from alphagov/format-thousands-returned-letters
Format 1000s properly on returned letters pages
2021-08-17 09:59:04 +01:00
Katie Smith
2a0181d909 Merge pull request #3995 from alphagov/update-accessibility-statement
Update accessibility statement with new issues
2021-08-13 16:46:48 +01:00
karlchillmaid
7b49dbb236 Fix link markup 2021-08-13 16:29:55 +01:00
karlchillmaid
342e0e9d05 Update bullet formatting and content 2021-08-13 16:29:55 +01:00
karlchillmaid
1fa2d6fc58 Update last tested date 2021-08-13 16:29:55 +01:00
karlchillmaid
18312cfdaa Update success criterion and review date 2021-08-13 16:29:55 +01:00
karlchillmaid
ab132bab2a Update commitment dates 2021-08-13 16:29:55 +01:00
karlchillmaid
be0cc955bd Update commitment dates 2021-08-13 16:29:55 +01:00
karlchillmaid
c5f498f1e8 Add dates and update WCAG acronym 2021-08-13 16:29:54 +01:00
karlchillmaid
6650e1663c Update content 2021-08-13 16:29:54 +01:00
karlchillmaid
2bb460fff2 Update content 2021-08-13 16:29:54 +01:00
karlchillmaid
c111a68b57 Update content 2021-08-13 16:29:54 +01:00
Tom Byers
8e0bcc84dc Update accessibility statement with new issues
We had an audit in February of this year but did
not update the accessibility statement to reflect
the issues identified as fixed or to include new
issues it produced.

Some of the dates for fixed have also not been
updated for a long time.

This adds those changes, with placeholders for
dates assigned to each issue.

This content is now ready for review. The dates
will be assigned when that is complete.
2021-08-13 16:29:54 +01:00
Chris Hill-Scott
db0738ac39 Format 1000s properly on returned letters pages
Our style is to comma-separate numbers in the 1000s for easier reading.
2021-08-12 15:51:22 +01:00
Chris Hill-Scott
196da2b1b7 Reduce expiry time to 22 hours 30 minutes
Theoretically the maximum expiry time of a broadcast should be 24 hours.
If it goes over 24 hours there can be problems.

However we want to make it more conservative to mitigate two potential
issues:

1. The CBC has a repetition period (eg 60 seconds) and a count (eg
   1,440). If these were slightly innaccurate or generous it could take
   us over 24 hours. For this reason we should give ourselves half an
   hour of buffer.
2. It’s possibly that the CBC could interpret a UTC time as BST or vice
   versa. Until we’re sure that it’s using UTC everywhere, we need to
   remove another whole hour as buffer.

In total this means we remove 1 hour 30 minutes from 24 hours, giving an
expiry time of 22 hours 30 minutes.
2021-08-10 13:41:03 +01:00
Chris Hill-Scott
8ff7fecf40 Expire test and operator alerts after 4 hours
While testing alerts on these channels the MNOs sometimes need to
restart their CBCs to make sure everything is failing over properly.

If the CBC does not come back up, for whatever reason, then we are left
in a state where the alert can’t be cancelled.

To minimise the impact to the public in this scenario we should keep the
expiry time at 4 hours for alerts sent on test channels. We recently
increased it back up to 24 hours for all channels, so this in effect is
reverting that change for channels that won’t be used in a real
emergency.
2021-08-09 15:15:58 +01:00
Ben Thorner
bb414ee3b9 Merge pull request #3991 from alphagov/update-thanks-page-content
Update content
2021-08-06 16:50:38 +01:00
Chris Hill-Scott
d20bf0aeb4 Merge pull request #3957 from alphagov/make-calculating-overlaps-faster
Make calculating overlapping areas faster
2021-08-06 16:00:00 +01:00
Chris Hill-Scott
b273037462 Use str.join to build query
This avoids the nasty slice operator to trim the trailing comma.
2021-08-06 13:28:41 +01:00
Chris Hill-Scott
de364bba3c Make overlapping_areas a cached property
It’s quite expensive to calculate and there’s no guarantee we’ll only use it once.
2021-08-06 13:28:41 +01:00
Chris Hill-Scott
5e1b96a3a7 Remove argument unpacking from get_areas
Making it only callable in one way is just less stuff to understand.
2021-08-06 13:28:40 +01:00
Chris Hill-Scott
6c766c24b6 Ensure that phones are only counted once
The page which shows the count of phones does some logic based on how
close the ‘will get’ and ‘likely to get’ numbers are. This means it
accesses the `BroadcastMessage.count_of_phones` and
`BroadcastMessage.count_of_phones_likely` properties multiple times.

These properties are computed fresh every time, and are quite expensive
to compute. By caching them in memory we can cut the page load time
approximately in half.
2021-08-06 13:28:40 +01:00
Chris Hill-Scott
775954da9d Avoid doing a single SQL query per overlapping area
To count phones in a custom polygon we need to work out the percentage
of overlap with each known area. This means we need to get each known
area from the database to compare it.

At the moment we do this by running:
- one SQLite query to get the details of all matching areas
- a loop, which performs one SQLite query *per area* to get the polygons

This commit reduces the number of SQLite queries to one, which uses a
`JOIN` to get both the details of the areas and their polygons.

This gives a speed increase of about 25% for a big area like
Lincolnshire.
2021-08-06 13:28:40 +01:00
Chris Hill-Scott
e7ec77c5bb Make calculating overlapping areas faster
By using the simplified polygons instead of the full resolutions ones
we:
- query less data from SQLite
- pass less data around
- give Shapely a less complicated shape to do its calculations on

This makes it faster to calculate how much of each electoral ward a
custom area overlaps.

For the two areas in our tests:

Place represented by custom area | Before | After
---------------------------------|--------|--------
Bristol                          | 0.07s  | 0.02s
Skye                             | 0.02s  | 0.01s
2021-08-06 13:28:40 +01:00
Ben Thorner
2f2be65465 Fix tests to match content updates 2021-08-06 13:10:31 +01:00