Commit Graph

3322 Commits

Author SHA1 Message Date
Tom Byers
0d6ef2977d Merge pull request #3465 from alphagov/add-scroll-to-reveal-method
Add scroll to reveal element method
2020-07-24 14:21:15 +01:00
Leo Hemsted
8f0c6e43c1 fix tests 2020-07-22 15:15:23 +01:00
Chris Hill-Scott
9958460ab3 Update tests for service permission
This commit makes the tests for the `broadcast` service permission more
robust by:
- adding coverage of endpoints that have been created since the test was
  first written
- checking that the endpoint also responds to a `post` request with a
  `403` (or `405` where it is a `get`-only endpoint)
2020-07-20 09:27:46 +01:00
Chris Hill-Scott
6704919a2d Add a confirmation step to cancelling a broadcast
It’s an irreversible action if you do click it, so it feels like an ‘Are
you sure?’ step is sensible. Follows the same pattern for deleting
templates, etc.
2020-07-20 09:27:44 +01:00
Tom Byers
e62fc846c7 Add test for scrollToRevealElement method 2020-07-17 11:57:19 +01:00
Chris Hill-Scott
4f859a69a6 Merge pull request #3527 from alphagov/broadcast-end-time
Let users choose when to end a broadcast
2020-07-17 10:43:10 +01:00
Chris Hill-Scott
2d7d800c64 Merge pull request #3528 from alphagov/fix-set-broadcast-permission
Fix setting of broadcast permission
2020-07-17 10:40:26 +01:00
Tom Byers
741ab9288f Add tests for 'data-show-now-as-default' on/off 2020-07-17 08:28:59 +01:00
Tom Byers
b5360c14cc Lowercase value of 'show-now-as-default'
To match the boolean value in JavaScript.
2020-07-17 08:28:59 +01:00
Tom Byers
e45bbcf99e Fix comparison of original categories with new
These tests make sure the sub-categories shown
when a category is selected are right but the
comparison looked for a direct match between the
labels for both types.

This looks for the category label in the
sub-category label instead, ie.

'Today at' in 'Today at 1pm'.

...instead of

'Today at' === 'Today at 1pm', which will always
fail.
2020-07-17 08:28:59 +01:00
Tom Byers
909f2d4678 Fix numbering on hours in radioSelect test 2020-07-17 08:28:59 +01:00
Tom Byers
636cb6825b Fix use of querySelector in radioSelect tests 2020-07-17 08:28:58 +01:00
Chris Hill-Scott
83156bd16e Let users choose when to end a broadcast
Different emergencies will need broadcasts to last for a variable amount
of time. We give users some control over this by letting them stop a
broadcast early. But we should also let them set a maximum broadcast
time, for:
- when the duration of the danger is known
- when the broadcast has been live long enough to alert everyone who
  needs to know about it

This code re-uses the pattern for scheduling jobs, which has some
constraints that are probably OK for now:
- end time is limited to an hour
- longest duration is 3 whole days (eg if you start broadcasting Friday
  you have the choice of Saturday, Sunday and all of Monday, up to
  midnight)
2020-07-17 08:23:10 +01:00
Chris Hill-Scott
03b4aabf5f Add a link to reject a broadcast
If a broadcast definitely shouldn’t go out (for example because it has a
spelling mistake or is going to the wrong areas) then we should have a
way of removing it. Once it’s removed no-one else can approve it, and it
isn’t cluttering up the dashboard.

This is a link (because it’s a secondary action) and red (because it’s
destructive, in that it’s throwing away someone’s work).
2020-07-17 08:07:44 +01:00
Chris Hill-Scott
a99b40304b Add button to approve broadcast
Since new broadcasts will go into `pending-approval`, we now need a way
of approving them.

This commit adds a button to this page to start (or approve) the
broadcast. This button is wrapped in a bordered box, to emphasise that
it’s something consequential.
2020-07-17 08:07:44 +01:00
Chris Hill-Scott
5b83db9768 Don’t start broadcasts immediately
We don’t want one person going full yolo and start broadcasting without
any oversight. This commit changes the flow so that the button on the
‘preview’ page puts the broadcast into `pending-approval`, rather than
directly into `broadcasting`.
2020-07-17 08:07:43 +01:00
Chris Hill-Scott
c270688fe4 Show pending broadcasts on dashboard
When we have an approval flow, `pending-approval` will be the state a
broadcast is in between being a draft and broadcasting.

This means it is the earliest stage at which a broadcast can appear on
the dashboard, so this commit adds a new section at the top of the
dashboard to display these broadcasts (since the dashboard is in a
reverse chronological order).

Rather than displaying the scheduled time, the extra information shown
is the person who drafted the broadcast, since I reckon you’ll be coming
to this page because they’ve asked you to approve their broadcast.
2020-07-17 08:07:40 +01:00
Chris Hill-Scott
e29a477eb1 Fix setting of broadcast permission
This was broken because current_service doesn’t update itself after
calling the `update` method of the API. So we thought we were changing
the permissions like this:
```
{'email', 'sms', 'letter'}
{'email', 'sms', 'letter', 'broadcast'}
{'sms', 'letter', 'broadcast'}
{'letter', 'broadcast'}
{'broadcast'}
```

But actually we were doing this:
```
{'email', 'sms', 'letter'}
{'email', 'sms', 'letter', 'broadcast'}
{'sms', 'letter'}
{'email', 'letter'}
{'email', 'sms'}
```

This commit changes the code to update the permissions like this:
```
{'email', 'sms', 'letter'}
{'broadcast'}
```

It does so by adding a new method to the service model which changes all
the permissions in one API call, and updates the tests to mock the
underlying API call, not the method on the model.
2020-07-16 19:44:20 +01:00
Chris Hill-Scott
5229373341 Make the broadcast dashboard update via AJAX
Same technique as we use for other pages that update via AJAX.

I’ve split the page up into separate chunks because the DiffDOM library
we use finds it easier to work out what’s changed when there are fewer
elements/a shallower tree.
2020-07-16 16:47:08 +01:00
Chris Hill-Scott
414e4b5834 Merge pull request #3520 from alphagov/broadcast-user-permissions
Make user permissions make sense for services with the broadcast permission
2020-07-16 14:59:57 +01:00
Katie Smith
756a17f8db Add filter for formatting a number as currency
This is used on the usage page, but is likely to become useful in other
places now that letter rates can be greater than £1.
2020-07-15 14:09:49 +01:00
Katie Smith
355e981028 Show international letters on the usage page
The api returns letter details split by postage, so international
letters are returned with a postage of `europe` or `rest-of-world` not
`international` and these rows need to be added together when the rate
is the same before they are displayed on the usage page.

To do this, we need to replace the postage of `europe` and
`rest-of-world` with `international`. The data then needs to be sorted
by postage and rate before the letter units for rows which are
international and have the same rate are added together.
2020-07-15 14:09:49 +01:00
Tom Byers
dfcddb757e Revert "Re-introduce govuk checkboxes" 2020-07-15 13:41:34 +01:00
Tom Byers
86f70ae9fa Merge pull request #3476 from alphagov/introduce-govuk-checkboxes
Re-introduce govuk checkboxes
2020-07-15 13:14:19 +01:00
Chris Hill-Scott
cc925238c7 Merge pull request #3518 from alphagov/view-broadcast-page
Add a page to view a single broadcast
2020-07-15 11:42:45 +01:00
Chris Hill-Scott
da29d35482 Merge pull request #3524 from alphagov/no-templates-message-broadcast
Add ‘no templates’ message for broadcast services
2020-07-15 11:37:56 +01:00
Chris Hill-Scott
c20958ef34 Clean up test formatting
Ensures that:
- test name reflects what it now does
- only one parameter per line
- argument order in parameterize matches argument order in function
  definition
2020-07-15 09:16:06 +01:00
Chris Hill-Scott
fd05bed600 Remove references to email, text and letters in trial mode
We don’t know what trial mode for broadcast services is going to look
like, but it’s not going to involve sending emails.
2020-07-15 09:14:56 +01:00
Chris Hill-Scott
89dd64cbad Don’t let broadcast re-enable other channels
When a service is switched over to broadcast it has the email, text
message and letter permissions removed. And the links to switch these
settings back on are hidden.

This commit ensures that even if the user manually goes to the URLs for
these pages, they still won’t be able to switch the other channels back
on.
2020-07-15 09:13:46 +01:00
Chris Hill-Scott
9dfa48cfdd Don’t treat letters as a special case
This conditional comes from before we launched the letters feature.
Since we were only giving the letters permission to teams that we were
inviting, we didn’t want to confuse new users by mentioning letters.

Nowadays all new services will have the letters permission, so this
check is redundant.
2020-07-14 15:00:57 +01:00
Chris Hill-Scott
008e4befb4 Add ‘no templates’ message for broadcast services
This shouldn’t talk about emails, text messages or letters.
2020-07-14 14:59:46 +01:00
Tom Byers
2b49e5eb7c Make tests work with new template list HTML
Adds the extra text added to each checkbox label.
It's a copy of the text of the link in the same
list item which does add a lot of duplication to
the test data.

This reformats a lot of the test data, stacking it
to separate out the duplicate items.
2020-07-14 10:41:09 +01:00
Tom Byers
05088037d2 Fix issues in tests from new fields 2020-07-14 10:41:09 +01:00
Chris Hill-Scott
94434b36e7 Only show relevant permissions on the team members page
Since users of broadcast services will always have the view dashboard
permission and never have the API keys permission we can hide these. And
we should re-label the permissions to make sense in the context of
broadcasting.
2020-07-14 09:46:55 +01:00
Chris Hill-Scott
72c1b3d8a1 Only show relevant user permissions for broadcast services
For services with the broadcast permission this hides:
- the ‘View dashboard’ permission (and defaults it to _checked_) because
  all users of broadcast services will need to see the dashboard
- the ‘Manage API keys’ permission (and defaults it to _not checked_)
  because we don’t offer an API integration for broadcast services yet
  – if we do we won’t want existing users to automatically get the
  permission

It relabels:
- the ‘Send’ permission to ‘Prepare and approve’ to match the current,
  slightly clunky language on the templates page
- the ‘Manage settings’ label to not refer to ‘usage’ because broadcast
  services won’t incur cost
2020-07-14 09:45:42 +01:00
Chris Hill-Scott
c17db333d3 Hide email, text message and letter settings
Services with the broadcast permission won’t be able to send emails,
text messages or letters. So we should avoid confusion by removing any
reference to these things.
2020-07-13 09:59:05 +01:00
Chris Hill-Scott
97aca503f7 No emails, texts or letters for broadcast services
To make the interface as simple as possible we don’t want to mix up
sending other types of communication where services have the broadcast
permission.

This commit removes the other permissions once a service has been given
the broadcast permission by a platform admin user.
2020-07-13 09:58:58 +01:00
Chris Hill-Scott
2a62ba9cbb Redirect to ‘view’ page after cancelling
This is better confirmation of your action than the dashboard, because
everything will stay the same except the thing you’ve just done.
2020-07-10 15:56:07 +01:00
Chris Hill-Scott
15611d67d3 Remove ‘Stop’ links from dashboard
Now you have to click in to cancel a broadcast instead.
2020-07-10 15:55:52 +01:00
Chris Hill-Scott
7d6dffc098 Add a page to view a single broadcast
This commit adds a page to view a single broadcast. This is important
for two reasons:
- users need an audit of what happened when, and who else was involved
  in approving or cancelling a broadcast
- we need a place to put actions (approving, cancelling) on a broadcast
  so that you can confirm details of the message and the areas before
  performing the action
2020-07-10 15:55:05 +01:00
Chris Hill-Scott
3136d1a33b Implement sorting
Shows the broadcasts with the longest time still to live at the top. At
the moment this will be the same as the newest broadcasts, so we may
want to revisit this sort order when we have broadcasts of variable
duration.

For no-longer-live broadcasts we show the most-recently-finished at the
top, whether it finished naturally or was cancelled.
2020-07-10 09:57:06 +01:00
Chris Hill-Scott
44e177b402 Allow broadcasts to be cancelled
Currently this is a `get` request from the dashboard. Once we have a page
for viewing an individual broadcast it should probably show there
instead and be a `get`/confirm/`post` loop like for deleting a template.
2020-07-10 09:57:06 +01:00
Chris Hill-Scott
6b822f9fde Add broadcasts to the dashboard
Shows current and previous broadcasts. Does not add a page for viewing
an individual broadcast.

Broadcasts are split into live and previous.

Draft broadcasts are excluded from the dashboard.
2020-07-09 16:32:15 +01:00
Chris Hill-Scott
effe24893e Make the broadcast flow talk to the API
This commit removes the code the puts areas into the session and instead
creates and then updates a draft broadcast in the database.

This is so we can avoid session-related bugs, and potentially having a
large session when we start adding personalisation etc.

Once a broadcast is ready to go it is set to `broadcasting` straight
away with no approval. We’ll revisit this as we learn more about how
users might want to manage who can create and approve broadcasts.

The tests are a bit light in terms of checking what’s on the page, but
clicking through the pages is probably good enough for now.
2020-07-09 14:31:12 +01:00
Chris Hill-Scott
ea1c9f4059 Merge pull request #3509 from alphagov/fix-broadcast-library-examples
Fix examples on choose broadcast library page
2020-07-08 16:22:44 +01:00
Chris Hill-Scott
11032a1e7a Fix examples on choose broadcast library page
It should be `.get_examples()` (a method) not `.examples` (a property)
but Jinja swallows the error and prints nothing.
2020-07-08 16:02:16 +01:00
Chris Hill-Scott
60f9ea5f9c Hide template ID and redaction for broadcast templates
We’re not going to have an API for sending broadcasts at the moment, so
you don’t need the template ID for anything.

Broadcast also won’t contain personal information, or tokenised links,
etc, so there’s no need to redact them after sending.

Removing this things means the interface is less cluttered.
2020-07-08 15:49:32 +01:00
Chris Hill-Scott
653b6b3601 Fix test broken by merging
The test came from one branch, the correct value came from another.
2020-07-08 15:12:29 +01:00
Chris Hill-Scott
641bd41f8f Merge pull request #3506 from alphagov/broadcast-dashboard
Add a dashboard for broadcast services
2020-07-08 14:59:30 +01:00
Chris Hill-Scott
dd45fb99c6 Merge pull request #3505 from alphagov/broadcast-navigation
Hide irrelevant things from nav for broadcast services
2020-07-08 14:59:25 +01:00