Commit Graph

11779 Commits

Author SHA1 Message Date
Katie Smith
08084dfbd2 Merge pull request #3988 from alphagov/back-link-location
Move backlink out of `<main>`
2021-08-06 10:10:47 +01:00
Katie Smith
245d9ed75e Fix styling for platform admin template
The layout for the platform admin base template needed to be changed so
that the back link appears in the same place as before.

Previously, the left hand nav was inside `<main>`, but that did not need
to be and was inconsistent with other pages, so has been taken out.
2021-08-03 11:28:15 +01:00
Katie Smith
f1d9f2ab19 Remove back_link parameter from page_header macro 2021-08-03 11:28:15 +01:00
Katie Smith
0f0b8b8ae4 Move back link outside of main where it was used in the page header
The page_header macro includes an optional back link. Since the
page_header is always used inside `<main>`, where the back link should
not be, this stops setting the back link in the page header and instead
sets it in the new `backLink` block.
2021-08-03 11:28:15 +01:00
Katie Smith
1860b2b690 Move back link above main content for straightforward cases
This moves the back link to be above the `<main>` tag by making use of
the new `backLink` block. This doesn't change the pages which are using
a back link as part of the `page_header` macro yet.
2021-08-03 11:28:15 +01:00
Katie Smith
0b9f1053b3 Add backLink block to templates
This will be used to put the back link in, since it it is before the
`<main>` tag. We could have used the `beforeContent` block directly, but
that sometimes already has content in - this means it's not clear when
you also need to use `super()` inside the block and when you don't.
2021-08-03 11:28:15 +01:00
Katie Smith
c7c4c6543a Delete unused templates
service-set-broadcast-account-type.html stopped being used in a0f54539cc.
set-letter-contact-block.html stopped being used in 45697aac43
2021-08-03 11:28:15 +01:00
Pea Tyczynska
af6b1d38b5 Merge pull request #3984 from alphagov/handle-cancel-letter-errors-from-api
Catch cancel_letter errors from API
2021-08-03 11:05:46 +01:00
Ben Thorner
703516cbec Merge pull request #3987 from alphagov/update-sizewell-name-178774818
Rename demo area to match govuk-alerts
2021-08-03 10:21:25 +01:00
Ben Thorner
297ab3e5ae Rename demo area to match govuk-alerts
Relates to: https://github.com/alphagov/notifications-govuk-alerts/pull/152

I ran the "create-broadcast-areas-db.py" script to regenerate the
Sqlite DB. Existing alerts with the old naming still appear correctly,
and since we don't (yet) store this text in the DB, there's nothing
more to update.
2021-08-02 15:34:55 +01:00
Chris Hill-Scott
0363181dae Merge pull request #3985 from alphagov/revert-3800-reduce-default-broadcast-expiry
Revert "Reduce default broadcast expiry time"
2021-07-30 10:16:30 +01:00
Chris Hill-Scott
2446e97753 Revert "Reduce default broadcast expiry time" 2021-07-30 09:39:08 +01:00
Ben Thorner
0e2f41c38c Merge pull request #3976 from alphagov/eradicate-roles-178770155
Replace the term "role" everywhere
2021-07-28 13:03:05 +01:00
Pea Tyczynska
e1420e7ff7 Catch cancel_letter errors from API
When we catch such error, if the message is recognised,
show the message and redirect user to view_notification page.
2021-07-28 12:55:06 +01:00
Ben Thorner
354cd8bb16 Replace remaining uses of the term "role"
In one case I did this by refactoring the code to avoid the need
for the "role" variable in the first place.
2021-07-28 12:37:18 +01:00
Ben Thorner
dcfff87cc0 Continue to remove "roles" terminology
This renames the two functions we have to translate between UI and
DB permissions, as well as some of their associated variables to
make it clearer which kind of permission they contain.
2021-07-28 12:37:17 +01:00
Ben Thorner
ba9865e62e Start to remove use of the term "roles"
We don't use this term consistently and it's not defined anywhere.
Since most of the Admin app deals with user-facing permssions, it's
OK to just use the term "permissions". Where both types of permission
are present in the same file, we can more clearly distinguish them
as "UI permissions" and "DB permissions".
2021-07-28 12:37:16 +01:00
Ben Thorner
a38baa0bd8 Rename unclear "permissions" attributes
These are more than a list of permissions: each item includes the
label to use when displaying it as an option on a form. Switching
to a name that reflects how the attributes are used will help to
avoid confusion when we rename some of the other attributes in the
same file in later commits.
2021-07-28 12:37:15 +01:00
Ben Thorner
f5580b87dc Move tests to match where the code is located
These tests are unrelated to the others in test_permissions.py. We
should try and structure our tests the same as the code under test
so that it's clear where new tests should go.
2021-07-28 12:36:43 +01:00
Ben Thorner
1127a03c32 Move and rename roles_and_permissions.py
This file does not represent a model, but rather a set of utilities
that are specific to user permissions (vs. service permissions).
2021-07-28 12:36:40 +01:00
David McDonald
2dd48de1a7 Merge pull request #3981 from alphagov/single-quote-sms-sender
Add support for single quote in SMS sender name
2021-07-27 09:43:33 +01:00
David McDonald
a6cac27957 Allow straight single quote in sms sender names
This is so we can allow the sender name 'UC' for DWP.

Note, this is specifically only straight single quotes and not curly
quotes or double quotes. Curly quotes are not supported in the GSM
character set (https://en.wikipedia.org/wiki/GSM_03.38). There is
currently no defined user ask to support double quotes in sms sender
names.

I have tested this by sending a message through both Firetext and MMG to
make sure they both support the single quote character in SMS sender
names.

DWP also have had no particular issues using the SMS sender name with
their existing system in the past either.
2021-07-27 09:26:16 +01:00
Katie Smith
dd9d652fbf Merge pull request #3979 from alphagov/permissions-refactor
Stop checking for `send_messages` permission for broadcast pages
2021-07-26 15:20:11 +01:00
David McDonald
65bdc7f5a4 Refactor of test cases into parametrized tests
No reason this shouldn't be parametrized. It will be neater, more
extendable and give better error messages

No functionality change, however I did slightly adapt one or two of the
test cases (for example to change the 11 characters or fewer test to
test on the boundary with 12 characters rather than many more).
2021-07-26 14:33:54 +01:00
Katie Smith
5277f734d9 Test the POST .approve_broadcast_message explicitly in the code
Previously, to get the the `.approve_broadcast_message` endpoint, we
were issuing a POST request to `.view_current_broadcast`. The
`.view_current_broadcast` only has a GET endpoint defined for the
`/services/<uuid:service_id>/current-alerts/<uuid:broadcast_message_id>`
route, so the request would end up at the `.approve_broadcast_message`
which defines the POST endpoint for that path.

This changes the tests to POST directly to `.approve_broadcast_message`
to avoid confusion.
2021-07-26 13:59:36 +01:00
Katie Smith
a7a1172e22 Split out the tests for 'New alert' button on broadcast dashboards
The 'New alert' button was being tested in the same tests as the tests
for the page content for the broadcast dashboards. Now that you only see
the button if you have the `create_broadcasts` permission, this adds a
new test just for the button so that the test for the page content can
be used for both broadcast permissions.
2021-07-26 13:59:36 +01:00
Katie Smith
bb4cd1ca07 Remove unused fixtures and freeze_time from test_broadcast.py 2021-07-26 13:59:36 +01:00
Katie Smith
761af69a00 Remove active_user_broadcast_permissions fixture
This wasn't adding anything now that we have two new and more specific
fixtures, `active_user_create_broadcasts_permission` and
`active_user_approve_broadcasts_permission`, that can be used instead.

`manage_templates` has now been removed from the `create_broadcasts`
permission, so this also adjusts the fixture for a user who can create
broadcasts.
2021-07-26 13:58:39 +01:00
Katie Smith
93ce0d4977 Remove send_messages permission from broadcast template page
This permission can be removed from the check to see whether the "Get
ready to send" link displays for broadcasts.
2021-07-26 13:58:23 +01:00
Katie Smith
8b08661902 Remove check for send_messages permission from broadcast pages
The `send_messages` permission has been deprecated for use with
broadcast services, so we can drop support for it in the code. We
were supporting both the old permissions and new permissions
(`create_broadcasts` and `approve_broadcasts`) while we switched people
over.

This removes `send_messages` from the `user_has_permissions` decorator
around the broadcast routes and from the page to view a broadcast and
broadcast dashboards. We can now git rid of a lot of the parameterization
that was temporarily added to the tests.
2021-07-26 10:58:16 +01:00
Chris Hill-Scott
b5fa6aeb33 Merge pull request #3977 from alphagov/alerts-permissions-labelling
Let people ‘add’ templates separately from ‘creating’ alerts
2021-07-26 10:13:32 +01:00
Chris Hill-Scott
b71f0c6795 Disambiguate sent and created
At the moment we say that you either ‘add’ an alert or ‘send’ it.

This is confusing because:
- an alert isn’t received on people’s phones until it’s approved, so
  this is really when it is ‘sent’ conceptually
- an alert can be rejected before anyone receives it, so the UI can say
  an alert that no-one ever received was sent

This commit re-labels things so that the the first part of the process
is ‘creating’ the alert.

This makes all the permissions nice and distinct from each other. Adding
templates and adding alerts feel conceptually quite different things
(what are you adding the alert to?).
2021-07-23 10:07:05 +01:00
Chris Hill-Scott
694d7cc2ff Split the templates permission out again
It will likely be the same people who have permission to create alerts
and edit templates (maybe someone in a comms role).

But combining the two permissions makes the options presented in the
form feel clunky because ‘alerts’ and ‘templates’ are conceptually quite
different.

So I think it makes sense to keep the templates permission the same as
it is for regular Notify services.
2021-07-23 10:07:04 +01:00
Chris Hill-Scott
f05e13edf3 Remove grid column from edit user page
We don’t restrict the column width on the invite user page. Having it
restricted makes the hint text wrap awkwardly when editing users on an
Emergency Alerts service.

By removing the grid column the hint text looks better.
2021-07-23 10:07:03 +01:00
Chris Hill-Scott
8d9e415539 Merge pull request #3978 from alphagov/pin-eventlet
Add Pyup comment to requirements.txt
2021-07-23 10:06:42 +01:00
Chris Hill-Scott
fab44e016a Add Pyup comment to requirements.txt
This matches what’s in requirements.in, but the Pyup comments don’t
automatically get copied when generating requirements.txt. This causes
Pyup’s safety CI to complain we’re using a version with a known
vulnerability (which doesn’t affect us since we don’t use websockets).
2021-07-23 09:01:53 +01:00
Leo Hemsted
80cfbacd84 Merge pull request #3974 from alphagov/deleted-template
dont let people get into one-off flow for deleted templates
2021-07-22 13:14:08 +01:00
Leo Hemsted
5da69dd495 dont let people get into one-off flow for deleted templates
previously we'd skip the template page entirely if someone didnt have
manage templates/api keys permission. however, if the template is
deleted you'd then go through the flow entering placeholders and stuff
before it would then crash when trying to send.

instead, just bounce the user to the template page. It has the content
and says when the template was deleted.
2021-07-22 11:47:07 +01:00
Ben Thorner
6232858490 Merge pull request #3970 from alphagov/audit-perm-changes-178770155
Audit permissions when they change for a user
2021-07-22 09:37:23 +01:00
Ben Thorner
832422fc66 Replace "admin roles" with "ui permissions"
In response to: [1].

While this does introduce a new term ("admin roles" is still used
elsewhere in the code), I plan to fix this in a follow-up PR (it
turned out to be quite a big change to do on this branch).

[1]: https://github.com/alphagov/notifications-admin/pull/3970#discussion_r673292339
2021-07-21 16:19:56 +01:00
Ben Thorner
9fafc092f7 Audit permissions when adding a user to a service
This is useful information to store for the event, which would be
lost if someone subsequently changed them.

Rather than updating lots of mock assertions, I've replaced them
with a single test / assert at a lower level, which is consistent
with auditing being a non-critical function.
2021-07-21 15:32:04 +01:00
Ben Thorner
171f911237 Audit when user permissions are changed
I've used the term "admin_roles" in the event data to try and show
that these are not the permissions we store in the DB. This is the
name we use for the abstracted form of permissions in the Admin app.
While we could store the DB permissions, that would be a bit more
effort and arguably it's clearer to keep the event data consistent
with the options the user actually saw / chose.
2021-07-21 15:32:03 +01:00
Ben Thorner
2241b119b0 Split (has_)permissions_for_service method
This avoids duplicating the code to get user permissions ("admin
roles") for a service, which we'll need in the next commit.
2021-07-21 15:32:02 +01:00
Ben Thorner
0f87ffe093 Move inline import to top of file
Usually we have imports at the top. It looks like the reason for
them being inline was to avoid a circular import, but we can also
avoid this by not importing everything from the app module.

Since we're about to add more imports from event_handlers, now is
a good time to refactor them. Note this matches how we import the
event handlers in every other module.
2021-07-21 15:32:01 +01:00
Katie Smith
d414e6d345 Merge pull request #3936 from alphagov/bcast-permissions
Use the new broadcast permissions
2021-07-20 11:21:28 +01:00
Katie Smith
6a29361071 Re-name and re-order some view broadcast tests
This tries to make the naming slightly more consistent and groups
together tests for the same thing.
2021-07-19 14:40:14 +01:00
Katie Smith
0249f1602d Change hint text for the broadcast form 2021-07-19 14:40:14 +01:00
Katie Smith
103cf4890b Add paragraph to broadcast settings form
The form is going to change to remove all existing permissions when it
is submitted, so this adds a paragraph to explain that.
2021-07-19 14:40:14 +01:00
Katie Smith
7e8c638865 Change /broadcast/view-message.html page to work with both permissions
The buttons and links on this page now work with the original
permissions and the two new broadcast permissions. Since the new
broadcast permissions have the effect of splitting the `send_messages`
permission this means that additional sections of if/else logic were
required.
2021-07-19 14:40:14 +01:00
Katie Smith
7572a97436 Use new permissions for 'Prepare broadcast' button on templates page 2021-07-19 14:40:14 +01:00