Commit Graph

3581 Commits

Author SHA1 Message Date
Leo Hemsted
93d1137474 move service to broadcast org when broadcasting is enabled
we want to keep track of all broadcast services across govt easily. As
such, when broadcasting is enabled for a service, we've decided we're
going to add the service to a special broadcasting organisation.

This organisation is defined in the config file. It's hard coded for
production, if you want to test locally, you should set
BROADCAST_ORGANISATION_ID in your local environment.
2020-09-22 18:18:00 +01:00
Chris Hill-Scott
f50ef84c0d Suggest previously-used areas when adding new area
If you’re adding another area to your broadcast it’s likely to be close
to one of the areas you’ve already added.

But we make you start by choosing a library, then you have to find the
local authority again from the long list. This is clunky, and it
interrupts the task the user is trying to complete.

We thought about redirecting you somewhere deep into the hierarchy,
perhaps by sending you to either:
- the parent of the last area you’d chosen
- the common ancestor of all the areas you’d chosen

This approach would however mean you’d need a way to navigate back up
the hierarchy if we’d dropped you in the wrong place. And we don’t have
a pattern for that at the moment.

So instead this commit adds some ‘shortcuts’ to the chose library page,
giving you a choice of all the parents of the areas you’ve currently
selected. In most cases this will be one (unitary authority) or two
(county and district) choices, but it will scale to adding areas from
multiple different authorities.

It does mean an extra click compared to the redirect approach, but this
is still fewer, easier clicks compared to now.

This meant a couple of under-the-hood changes:
- making `BroadcastArea`s hashable so it’s possible to do
  `set([BroadcastArea(…), BroadcastArea(…), BroadcastArea(…)])`
- making `BroadcastArea`s aware of which library they live in, so we can
  link to the correct _Choose area_ page
2020-09-22 17:33:04 +01:00
Tom Byers
a75cde039f Merge pull request #3624 from alphagov/add-accessible-letter-specification
Add accessible letter specification
2020-09-22 16:36:15 +01:00
Chris Hill-Scott
2d64306e88 Link to specification page, not PDF directly 2020-09-22 15:49:38 +01:00
David McDonald
a538329d0e Use new redis key for service templates and broadcasts
We can drop use of the old key as we no longer need to read data from
the old key. Either data exists in the new key and we read it from there
or data doesn't exist in the new key and we go to the API to get it and
then set it in redis.

Note, the previous commit is important because it means we aren't at
risk of when this commit is being deployed out, of us getting stale data
from the old key.
2020-09-21 17:37:27 +01:00
David McDonald
e3baa9ba35 Step 1 of renaming cache keys for templates
We want to change cache keys for templates and broadcasts to include
their service ID. So cache keys should change from
`template-{template_id}-versions` to
`service-{service_id}-template-{template_id}-versions`.

The first step of this which needs to be deployed as a change first is
to delete both keys when updating service templates (even if they key is
not yet set). This means that when we release code in the next PR to
start setting the new key, we won't run into a case where either the old
or the new key can remain set with stale data.
2020-09-21 14:04:10 +01:00
Leo Hemsted
422825f03b Merge pull request #3629 from alphagov/fix-broadcast-back-links
fix back links for broadcast libraries
2020-09-21 11:37:21 +01:00
Leo Hemsted
a6b25b5991 add back links
previously the back link went to choosing a library.

Now, if you view a district from a county, go back to the county page.
Otherwise, go back to the top level of the library.
2020-09-21 11:24:05 +01:00
Chris Hill-Scott
5c22bd56ce Add a tour screen once a broadcast is approved
For a training broadcast the user doesn’t get that immediate feedback
that something has happened, like they would with a real alert, or even
sending themselves a text message.

This commit adds another tour-style page which will interrupt their
journey and hopefully reinforce the message we’ve given them earlier in
the tour.

We’re adding this because we’ve found in research that users don’t have
a good grasp of the consequences and severity of emergency alerts,
versus regular text messages.
2020-09-21 09:41:19 +01:00
Tom Byers
a9c1d64326 Add tests for the focus style & new attributes 2020-09-19 22:03:45 +01:00
Katie Smith
a67ea9a623 Fix the display of sms statuses 2020-09-18 16:26:08 +01:00
Tom Byers
704de9ebf3 Add tests for various different counter states 2020-09-18 12:10:32 +01:00
Tom Byers
2f18e4b2f0 Update test helper that generates checkboxes
It was using GOVUK Elements HTML and we have since
moved to GOVUK Frontend.
2020-09-18 11:50:32 +01:00
Tom Byers
3719479356 Add tests for live-search announcements 2020-09-17 14:38:40 +01:00
Chris Hill-Scott
8a413bec91 Merge pull request #3617 from alphagov/population-estimates
Give estimates of the number of phones in a broadcast area
2020-09-17 11:41:00 +01:00
Chris Hill-Scott
4c7180ca75 Update tests/app/broadcast_areas/test_broadcast_area.py
Co-authored-by: David McDonald <idavidmcdonald@me.com>
2020-09-17 11:09:52 +01:00
Chris Hill-Scott
ae17ff1f07 Fix significant figure round for value of 0
You can’t do `log10(0)` in maths, so we need to handle it as a special
case.
2020-09-17 11:08:36 +01:00
Chris Hill-Scott
76244d8c07 Handle areas with missing data
At the moment there are some areas which have:
- a `count_of_phones` value of `None`
- no sub-areas

This is wrong, but until we fix the data the phone counting code needs
to handle this.

This commit:
- adds the `or 0` in the right place (where it will catch these areas
  with missing data)
- adds a test which checks these areas, and compares them to other kinds
  of areas
2020-09-17 11:02:22 +01:00
Chris Hill-Scott
e232950d46 Add tests for the population calculations
Now that this function is split out we can unit test it to make sure
that the expected numbers are coming out of it.
2020-09-16 14:45:54 +01:00
Chris Hill-Scott
49195cb0d3 Rename constants to populations
This is a better name for the module because it’s:
- not just constants, there’s a method in here now
- only stuff to do with populations, not other kinds of constants
2020-09-16 14:45:45 +01:00
Chris Hill-Scott
b9f75218d1 Add tests to ensure all areas have a count 2020-09-16 11:20:22 +01:00
Tom Byers
b4d985e071 Rewrite test descriptions
They originals didn't explain what the tests do.

We could test the contents of the range but that
would be testing the Range API, rather than our
use of it.

The tests test how we use that API for these
scenarios so their descriptions should say this.
2020-09-15 17:07:01 +01:00
Tom Byers
956f5d4c3e Make copy to clipboard work with prefixes
The prefix was being included in the selection
copied.
2020-09-15 17:04:03 +01:00
Chris Hill-Scott
8ea3f0141c Give estimates of the number of phones in a broadcast area
We need to give people a better feel for the consequences of
broadcasting an alert. We’ve seen in research that some users will
assume it is subscription based, or opt-in, rather than going to every
phone in the area.

I reckon that the most effective way to communicate this is to put some
numbers next to the areas, to give people an idea of how many people
will get alerted.

We can estimate how many phones are in an area by:
- taking the population of all electoral wards in that area
- multiplying it by the percentage of people who own an internet
  connected phone[1]

The Office for National Statistics publish both these datasets.

The number of people who own an intenet connected phone varies a lot by
age. Since the population data for each ward is broken down by age we
can factor this in. Simplified, the calculation looks like this:
- take the _Abbey_ ward of _Barking and Dagenham_
- in this ward there are 26 people aged 80
- 40% of people over 65 have an internet-connected phone
- therefore 10 of these 80-year-olds would be likely to receive a
  broadcast
- (repeat for all other ages)

These numbers won’t be exact, but should be enough to give people a feel
for the severity of what they’re about to do. We can see if they acheive
this aim in user research.

1. This is a proxy for the number of people who are likely to have a 4G
   capable phone, because only 4G capable phones will be receiving
   broadcasts to begin with
2020-09-14 16:26:09 +01:00
Leo Hemsted
ef0564f046 generate library summary in python
much simpler than sqlite.

also remove oxford commas

Co-authored-by: Chris Hill-Scott <me@quis.cc>
2020-09-14 15:25:04 +01:00
Tom Byers
9cba1e17e0 Merge pull request #3619 from alphagov/add-context-to-letter-template-links
Give links context on letter template page
2020-09-11 14:07:25 +01:00
Tom Byers
84b7227d4a Merge pull request #3605 from alphagov/prevent-user-name-email-being-cut-off
Prevent user name email being cut off
2020-09-10 15:10:58 +01:00
Chris Hill-Scott
f824b3a5eb Give specific error if international letters off
If a service doesn’t have permission to send international letters but
someone tries to upload a letter with a valid international address we
just tell them that the last line must be a UK postcode.

This is a bit opaque and:
- suggests that we’re not recognising at all that it’s not a UK letter
- doesn’t explain why it must be a UK postcode

This commit adds a new, error message which tells users why their letter
can’t be sent. And hopefully will give them a better idea of how to
resolve the problem, if they really do need to be able to send
international letters.
2020-09-10 11:25:17 +01:00
Tom Byers
c777b0eafb Give links context on letter template page 2020-09-09 21:27:58 +01:00
Chris Hill-Scott
5e579ed45c Merge pull request #3595 from alphagov/map-key
Add a key to the map
2020-09-09 16:03:27 +01:00
Leo Hemsted
9e132263d2 make tests pass (acknowledge that code is wrong)
i really don't want to fix this right now but that total isn't quite right
2020-09-09 14:39:13 +01:00
Leo Hemsted
256d2b2b60 add counties page
What was previously ward -> local authority is now a ward -> local
authority -> county. County only covers rural counties and not
metropolitan boroughs and other unitary authorities. Previously, there
was a page full of local authorities (unitary authorities and
districts), and each one of those would have a list of electoral wards.
However, now there are counties that contain a list of districts - so
this needs a new page - a checkbox for "select the county" and then a
list of links to district pages.

If you want to select multiple districts, you'll need to go into each
one of those sub-sections in turn and click select all.

Needed to tweak the query to retrieve the list of areas in a list for a
library. Previously, it just returned anything at top level (ie: didn't
have a parent). However, rural districts now have parents (the rural
counties themselves). So the query now returns "everything that isn't a
leaf node", or in more specific terms, everything that has at least
other row referring to it as a parent. So no electoral wards, since
they dont have any children, but yes to districts and counties.
2020-09-09 14:39:12 +01:00
Chris Hill-Scott
78fcf8bf35 Merge pull request #3613 from alphagov/show-international-immediately
Show international postage as soon as address is entered
2020-09-09 09:59:52 +01:00
Chris Hill-Scott
cd7260dd80 Show international postage as soon as address is entered
At the moment we don’t check whether a one-off letter is international
until the user’s clicked send. It’s more accurate to show that the
letter will be sent internationally as soon as we know the address.

Depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/786
2020-09-09 09:20:56 +01:00
Chris Hill-Scott
f553158846 Add estimated areas for non-visual users
Since the key relies on visual association between the shapes on the
maps and the styling of the key, it won’t work for non-visual users.
An alternative way of giving them the same information is by providing
the size of the area numerically.
2020-09-08 16:56:39 +01:00
Tom Byers
9e6daecba3 Merge pull request #3610 from alphagov/fix-pill-tab-problems
Fix pill tab problems
2020-09-08 14:51:12 +01:00
Pea M. Tyczynska
88a5fd56bf Merge pull request #3609 from alphagov/send-polygons-to-api
Send simple polygons to API along with areas
2020-09-08 12:23:12 +01:00
Rebecca Law
7cae303104 Fix unit tests for changes to the pill component. 2020-09-08 10:12:23 +01:00
Chris Hill-Scott
821d9f20e0 Merge pull request #3604 from alphagov/no-assert-not-called
Remove uses of .assert_not_called
2020-09-07 12:58:20 +01:00
Chris Hill-Scott
3af8ed521d Merge pull request #3594 from alphagov/fix-live-search-sub-areas
Don’t filter ‘All of’ choice with live search
2020-09-07 12:57:58 +01:00
Chris Hill-Scott
0459e26be9 Show address line 7 not postcode in example spreadsheet
Since the letter preview will now show address line 7, the example
spreadsheet we give should match.
2020-09-07 12:00:27 +01:00
Rebecca Law
52954191fa Merge branch 'master' into international-letters-form 2020-09-07 09:45:17 +01:00
Rebecca Law
0f64d4d136 Merge pull request #3564 from alphagov/int-letters-content
Add international letter rates to pricing page
2020-09-07 08:13:43 +01:00
Pea Tyczynska
3bfe3a2bf7 Send simple polygons to API along with areas
When creating broadcast message, or updating it.
We want to send simple polygons to API so we can
later relay them to the broadcast provider.

Test that update broadcast message sends polygons correctly
2020-09-04 16:55:02 +01:00
Tom Byers
be83ea36ea Change list items on /users page
Change the HTML & CSS for user-list-item's to
support their content being split into 2 columns
of a grid instead of the edit link being
positioned absolutely.

Also includes:
1. removes `<div>`s from `<ul>` (non-valid HTML)
2. split action link out from permissions list
3. split summary of folder permissions out from
   permissions list
4. introduces a class for blocks of text that
   appear when there are no items.
5. fixes tests broken by changes to HTML
2020-09-02 16:21:41 +01:00
Tom Byers
676a9297fe Merge pull request #3593 from alphagov/fix-link-and-button-text-across-pages
Fix link and button text across pages
2020-09-01 15:11:09 +01:00
Pea M. Tyczynska
84e3a7ffd5 Merge pull request #3601 from alphagov/only-govt-users-can-be-invited-to-broadcast-services
Broadcast: only approved domain users can be invited
2020-08-28 15:04:50 +01:00
Pea Tyczynska
e0faad6cea Only approved email domain users can be invited
to broadcast services. This is done to improve security.
2020-08-28 14:41:03 +01:00
Chris Hill-Scott
1e55a8cbbe Remove uses of .assert_not_called
I prefer to avoid `assert_not_called`, because if I make a typo like
this, the tests will still pass:
```
    app.invite_api_client.create_invite.asset_not_called()
```

It’s harder to have a false positive with the statement written this
way:
```
    assert app.invite_api_client.create_invite.called is False
```
2020-08-28 13:26:14 +01:00
Tom Byers
d446a91a8e Merge pull request #3591 from alphagov/fix-copy-to-clipboard
Fix copy to clipboard
2020-08-28 10:58:36 +01:00