Commit Graph

637 Commits

Author SHA1 Message Date
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
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
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
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
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
Katie Smith
0249f1602d Change hint text for the broadcast form 2021-07-19 14:40:14 +01:00
Chris Hill-Scott
f8d4617672 Refactor organisation invite form for reuse
It’s exactly the same code as `BaseInviteUserForm` so there’s really no
need to duplicate it (and means that changes we make to
`BaseInviteUserForm` in the future will get inherited).
2021-07-16 09:20:06 +01:00
Chris Hill-Scott
d749ee5cea Rename confusing variable
The reason the email address is considered invalid is because it is the
address of the person doing the inviting.

This commit renames the variable to be more specific and avoid confusion
with the email address of the person being invited.
2021-07-15 14:21:58 +01:00
Chris Hill-Scott
c3091223a9 Be strict about similar email addresses for alerts
We don’t want a single person to have two accounts on an emergency
alerts service because it would let them circumvent the two eyes
approval process.

We can go some way to mitigating against this by stopping people using
common methods that email providers use to alias email addresses. These
are:
- being case insensitive
- being insensitive to the position or number of dots in the local part
  of an email address
- using ‘plus addressing’

We already prevent the first one, this commit adds normalisation which
strip out the second two before doing the comparision with the current
user’s email address.
2021-07-15 13:55:50 +01:00
Chris Hill-Scott
9dd5c89252 Move two calls to str.lower next to each other
This means that we can rewrite `validate_email_address` to do a
different comparison without having to also change `__init__`

I’ve moved the platform admin check into its own conditional to keep the
line length manageable.
2021-07-13 15:38:13 +01:00
Ben Thorner
a1b4ccc246 Prevent auth type changing for any WebAuthn user
Previously we applied this restriction to Platform Admins, on the
assumption that all of them use a security key to log in. Rather
than making that assumption, we can explicitly check their login
method, which also supports rolling out the feature to more users.
2021-07-07 15:04:43 +01:00
Leo Hemsted
126f9cf6be fix bug stopping editing of permissions of webauthn platform admins
We hide the radio field in the HTML for platform admins, as we don't
want anyone to be able to change their auth type. However, when the form
is validated, the form has a field called login_authentication that it
expects a value for. It silently fails as it complains that when the
user POSTed they didn't select a value for that radio field, but the
error message is on the radio fields that don't get displayed to the
user so they'd never know.

Fixing this is actually pretty hard.

We use this form in two places, one where we have a user to edit, one
where we are creating an invite from scratch. So sometimes we don't know
about a user's auth type. In addition, radio buttons are mandatory by
design, but now sometimes we don't just want to make it optional but
explicitly ignore the value being passed in? To solve this, remove the
field entirely from the form if the user is a platform admin. This means
that if the code in manage_users.py tries to access the
login_authentication value from the form, it'll error, but I think
that's okay to leave for now given we concede that this isn't a perfect
final solution.

The tests didn't flag this previously as they tried to set from sms_auth
(the default for `platform_admin_user`) TO email_auth or sms_auth. Also,
the diagnosis of this bug was confounded further by the fact that
`mock_get_users_by_service` sets what is returned by the API - the
service model then takes the IDs out of that response and calls
`User.get_user_by_id` for the matching ID (as in, the code only uses
get_users_by_service to ensure the user belongs to that service). This
means that we accidentally set the form editing the current user, as
when we log in we set `get_user_by_id` to return the user of our choice
2021-06-29 15:53:48 +01:00
Chris Hill-Scott
2d36ec8214 Add support for the operator channel
Was just in one of those meetings where it felt like writing this would
take less time than I’d already spent talking about its relative
priority…

---

In the admin app you can already set the broadcast channel as 'test', 'severe' or 'government'.

Aim:
- Add the 'operator' channel to the list of channels you can pick for the admin app broadcast services

Note:
- The API already supports this - https://github.com/alphagov/notifications-api/pull/3262
- The CBC proxy does not yet support the operator channel and this will need a separate card. That card has not yet been written because the interface has not been agreed between us and the MNOs yet.
- Will need to have the ability to select the operator channel for just a single MNO like we do for the other channels
- If we add this, we shouldn't actually start using it until the MNO in question gives us the go ahead.

---

https://www.pivotaltracker.com/story/show/178485177
2021-06-14 08:48:12 +01:00
Ben Thorner
9ada8ad11e Remove redundant code to populate account type
This field is now only used on the confirmation page of the settings
form, where we pre-populate it with the hyphenated string it expects.
2021-06-07 17:51:11 +01:00
Ben Thorner
5bfe5f86de Simplify channel selection using radio buttons
This takes a similar approach as in the previous commit. Since the
"training channel" doesn't really exist, we need some extra code
to pre-select it if a service is already in training mode. As in
the previous commit, I've removed a few non-critical test cases
where we really don't need to test exhaustively.

Note that we also need some specific code to avoid pre-selecting an
option for non-broadcast services, which only used to work by fluke:
we would try to populate the field with (False, None, 'all'), which
isn't a valid combination, so nothing was selected.
2021-06-07 17:51:10 +01:00
Ben Thorner
b38cdcad63 Simplify network choice to optional radio buttons
Previously this field had to mimic the final hyphenated string of
the broadcast account type, even though it was only used to select
one of its components. The new, shorter choices make it easier to
simplify the test for the POST request.

I've also deleted a number of test cases for pre-selected radios.
This functionality isn't critical, so we don't need to exhaustively
test every single possible combination of values.
2021-06-07 17:51:09 +01:00
Ben Thorner
ef8cab7fa4 Simplify network choice form to use boolean radio
This follows the same pattern as in other forms [1].

[1]: 1b459d6692/app/templates/views/organisations/add-gp-organisation.html (L20)
2021-06-07 17:51:09 +01:00
Ben Thorner
5ce76b8b33 Add property to construct account type string
This allows us to start decoupling the form fields from the final,
hyphenated string, which we'll do in the next commits.

Note that I've also removed the conditional that changes the data
of the network field as part of validating it. We shouldn't change
data in validations, and having the new property directly above
makes it clear there's no need for this code.
2021-06-07 17:51:08 +01:00
Ben Thorner
e848643361 Simplify provider selection with '-all' suffix
Previously we had to cope with two forms of the hyphenated string
we use to represent a pending change in broadcast account type.
Using "all" to mean "all providers" matches the behaviour in the
API [1], and means we can remove some complexity.

"training-test-all" isn't ideal, since the provider is irrelevant
for a training mode service. However, this isn't much worse than
the previous "training-test", noting that the channel also has no
relevance. We'll iterate this in later commits.

[1]: 8e1a144f87/migrations/versions/0352_broadcast_provider_types.py (L14)
2021-06-07 17:51:01 +01:00
David McDonald
0fcb7778ac Merge pull request #3893 from alphagov/allow-provider-all-channels
Allow setting provider for any channel
2021-06-03 09:36:43 +01:00
Rebecca Law
24f4b3f3eb Merge pull request #3899 from alphagov/bump-utils-new-invalid-address-char
Bump utils version for new invalid address character
2021-05-27 13:53:38 +01:00
Rebecca Law
9a4b6de37d Bump utils version for new invalid address character 2021-05-27 13:04:46 +01:00
Pea Tyczynska
a10304d9c6 Merge pull request #3892 from alphagov/update-remove-webauthn-cred
Let admin user update and delete their security key
2021-05-25 14:33:00 +01:00
Pea Tyczynska
8501aa4ad6 Change name of the form and form field for consistency
Following PR review.

Also update function name for update name of security key in
user api client to be more specific.
2021-05-25 11:55:48 +01:00
Pea Tyczynska
56eac279df Show manage security key page with name change form 2021-05-25 11:40:41 +01:00
Ben Thorner
c5196fbf07 Allow setting provider for any channel
Previously we could only select a provider when using the test
channel, but this is also required for others channels when we
do tests on the production network with individual MNOs.

In order to reduce duplication and improve consistency, I've reused
the new broadcast_service_name_tag macro to show the setting.
2021-05-20 14:46:04 +01:00
Chris Hill-Scott
e2ef8cd36e Show error message if checkbox wasn’t checked
Because we were redirecting in all cases the error message wasn’t being
shown.

This commit changes the endpoint to respond with content (including an
error message) if the `POST` is not successful.
2021-05-18 15:58:41 +01:00
Chris Hill-Scott
7d66dadcd7 Add a confirmation checkbox for live broadcasts
We want people to be really sure before sending a live broadcast, not
just clicking through the green buttons.

This commit adds a checkbox which explains exactly the consequences of
what they’re about to do, tailored to the channel they’re on, and the
area chosen by the person creating the alert.
2021-05-18 15:58:41 +01:00
Chris Hill-Scott
e45bd485e8 Add conditional reveal to network selection
Rather than try to explain all/only just through words we can use some
interaction design to make the hierarchy of choices more explicit.
2021-05-12 16:22:44 +01:00
Chris Hill-Scott
a0f54539cc Add a second step for choosing networks
Only the test channel has the option to isolate messages to one network.

This commits makes the choices less confusing by only showing the
network choice to those who have selected the test channel.
2021-05-12 16:22:44 +01:00
Chris Hill-Scott
f640767f3d Add government channel
We have been asked to support the government channel so that:
- it can be tested
- the option to use it is available for the most severe of emergencies,
  where the public’s choice to opt-out is outweighed by the widespread
  risk to life
2021-05-12 16:22:43 +01:00
Chris Hill-Scott
ffd844b2a7 Add confirmation step to emergency alert settings
It feels quite dangerous that it’s just one click to make an emergency
alerts service live.

This commit adds a confirmation step which explains the consequences of
what you’re about to do.
2021-05-12 14:53:49 +01:00
Katie Smith
f7036825df Stop checking for allowed_broadcast_provider being None
The current_service.allowed_broadcast_provider is now always "all" or
one of the four providers, which means we can simply the code by not
checking if it is None.
2021-05-11 12:20:03 +01:00
Katie Smith
3485475270 Allow provider_restriction to be None or "all"
Until all the data is updated to always be "all", we have to handle the
case of provider_restriction being set to None or "all" (which mean the
same thing).

The code can be tidied up once the broadcast provider_restriction is never None.
2021-05-10 16:18:14 +01:00
Katie Smith
2f9e2dbc9d Send api the broadcast provider restriction of 'all', not 'None'
We're replacing the value of None with the value of all. API has been
updated to accept both values
(1767535def)
so this change starts sending notifications-api the value of "all".
2021-05-10 16:18:14 +01:00
Rebecca Law
5495de0b3b Remove some of the option we have for broadcast services.
This is the first step in making the UI easier for setting the
options for a broadcast service. Here we remove the options for
"Training mode" test channels. When we create a broadcast message for a trail mode service it is marked as stubbed and does not create a broadcast event that is sent to a provider.

The label for the form and setting page have been updated to reflect the
change.
2021-05-05 14:04:51 +01:00
Chris Hill-Scott
c95b2ef8b3 Allow users of the API to search templates by ID
For someone who has retrieved a template ID from their system the only
way to find it in Notify is:
- hack the URL
- click through every template, visually inspecting the ID shown on the
  page until you find the right one

Neither of these is ideal.

This commit adds searching by ID, for those services who have an API
integration. This means we don’t need to confuse teams who aren’t using
the API by talking about IDs.

This is similar to how we let these teams search for notifications by
reference[1]

1. https://github.com/alphagov/notifications-admin/pull/3223/files
2021-04-13 15:24:29 +01:00
David McDonald
3e80ba4734 Fix flake8 and isort errors
Note, isort now has default behaviour of searching recursively so we no
longer need the `-rc` flag
2021-03-08 18:48:56 +00:00
Katie Smith
1f9ea4a72f Stop adding required attribute to WTForm fields
WTForms now renders the `required` attribute if there is a validator
such as `DataRequired`. This was flagged in an accessibility audit as
being unnecessary since it doesn't conform to the Design System
recommendations, which state that "all form fields are considered
mandatory when navigating a government service unless otherwise denoted
by the word ‘(optional)’."

This uses the approach here https://github.com/wtforms/wtforms/pull/361
to overwrite the `render_field` method.
2021-02-24 14:36:21 +00:00
David McDonald
f8f3d44511 Add form to set service broadcast account type
Note, no option at the moment to set the service broadcast account type
as None, or back to without the broadcast permission. This has been done
for speed of development given the chance of us needing this is very
low. We can add it later if we need to.
2021-02-23 16:03:14 +00:00
Pea Tyczynska
36c72bb4cc View edit organisation billing details page 2021-02-16 14:46:13 +00:00
Pea Tyczynska
f0d94a009e Organisation notes visible on organisation settings page 2021-02-16 14:46:11 +00:00
Rebecca Law
f0ce2c6f5b Update utils to version 43.8.
Invalid characters for the first line of a postal address now include < >
2021-02-09 14:07:01 +00:00
Pea Tyczynska
25534dbee3 Remove 'billing' from option labels
They were unnecessary it turned out.
2021-02-03 10:30:02 +00:00
Pea Tyczynska
c60be7000a Add notes to edit billing details page
As per ticket and as per Caley's request, so everything can be
edited together.

Also pluralise labels for billing contact info, to indicate
that putting multiple in is ok, and widen the input fields so
that it is more comfortable to input multiple contact details.
2021-02-03 10:30:02 +00:00
Pea Tyczynska
079f371bc5 Update attribute names following changes in API 2021-02-03 10:30:01 +00:00
Pea Tyczynska
8f21caa87a Change service billing details
View page that lets you change service billing details and
update details on form submission.
2021-02-03 10:30:01 +00:00
Tom Byers
0cedf39992 Merge pull request #3781 from alphagov/add-govuk-radios-7
Add GOVUK radios [part 7]
2021-02-02 11:40:53 +00:00
Tom Byers
0459cbe24f Merge pull request #3768 from alphagov/add-govuk-radios-6
Add GOVUK radios [part 6]
2021-01-27 14:54:30 +00:00