Commit Graph

2306 Commits

Author SHA1 Message Date
Alexey Bezhan
6fa975e867 Send updated user folder permissions to the API
Integrates the folder permissions form with the updated API endpoint
to store changes in the user folders.

Since user folder permissions are returned in the full list of template
folders for the service we need to invalidate the cache key for it each
time we update user permissions.
2019-03-05 11:44:34 +00:00
Pea Tyczynska
7413423243 Display nested folders permissions form on user permissions page
We're reusing the logic for the `move_to` nested radios field for the
user folder permissions nested checkboxes.

The main difference between the two forms (aside from the different
input type) is that "Move" form contains the root "Templates" as an
option, whereas the folder permissions doesn't.

It turns out that, because of the way NestedFieldMixin.children and
select_nested macro are implemented the easiest way to get the desired
folder permissions behaviour is to add the root folder as a choice with
a `None` value and `NONE_OPTION_VALUE = None` set on the field, which
allows the `child_map` to be constructed but doesn't display the root
folder checkbox itself since it gets overwritten in the final `child_map`.
2019-03-05 11:44:34 +00:00
Rebecca Law
184ea5b92b Update the message when changing a users mobile phone number. 2019-03-04 11:14:35 +00:00
Chris Hill-Scott
4cae924379 Don’t prefil answer to research consent question
We were treating `None` (not answered) the same as `False` (previously
answered no).
2019-03-01 12:22:57 +00:00
Chris Hill-Scott
7ac9884dd5 Tag tickets that haven’t filled volumes 2019-02-27 17:34:24 +00:00
Chris Hill-Scott
5f4280cf81 Let people go live without filling the volumes
At the moment it 500s because it can’t format the `None` values as
numbers.

In the future we will stop people requesting to go live until they’ve
provided this info. For now it has to be optional.
2019-02-27 17:05:02 +00:00
Chris Hill-Scott
6a6b3f78b1 Revise error message for non-numeric responses
Things we talked about:
• asking users to write the number 'as numerals' or 'using digits' isn't
  very plain English
• the style guide says to use an example in the error `..., like 5,000`
  but not if you have an example in the hint text, so we can't do that
• I have reservations about 'correct format', because it sounds odd if
  you're not describing something like a phone number, NI number or
  credit card number.

Looking back through Request to Go Live tickets on Zendesk.
---

I got to September before I found anything that would count as invalid
under our new rules:

> Possibly around 1,000,000- not planning on implementing emails yet but
might change

I'll keep looking, but if most people enter the number according to the
hint example we might be able to go with a much simpler error just
prompting them to enter a number – no convoluted descriptions of what we
mean by a number

There seemed to be more problems when the Qs were about start volume and
peak volume. Users felt the need to explain their plans more.

Using 'number' instead of 'volume' is more explicit too – so that
probably helps.

In terms of errors:
`Enter the number of emails you expect to send`
`Enter the number of text messages you expect to send`
`Enter the number of letters you expect to send`
– will probably do it, right?
2019-02-27 15:13:42 +00:00
Chris Hill-Scott
9691ef27da Round max number limit down
A round number feels better than a very arbitrary-looking one.
2019-02-27 15:13:33 +00:00
Chris Hill-Scott
1a94137ff6 Add latest content
From: https://docs.google.com/document/d/1aykf1MjJH5y21Bz1ht6WJncb9cKu0fsPlac3-bkMPe8/edit
2019-02-27 15:13:23 +00:00
Chris Hill-Scott
61ac7fa069 Don’t reformat numbers if there are errors
It’s confusing to at the same time:
1. change what you’ve inputted
2. tell you it’s wrong

This commit makes it so that 1. only happens if 2. doesn’t.
2019-02-27 13:26:23 +00:00
Chris Hill-Scott
a24c853dce Also allow spaces in numbers
Apparently this is a French thing.
2019-02-27 13:23:15 +00:00
Chris Hill-Scott
9f63449384 Make answers to volume questions optional
It’s annoying and very ‘computer says no’ to make people type `0` in a
box. We can see from our analytics that this error is affecting about 7%
of users trying to go live.

This commit relaxes the validation to only require a number greater than
1 for at least one of the questions.

It also lets people enter their numbers comma-separated – like our
examples suggest – but normalises them to integers before sending them
over to the API.
2019-02-27 13:20:20 +00:00
Chris Hill-Scott
8791134c60 Move the ‘estimated usage’ questions
We get a bunch of requests to go live where people have told us they're
going to send email but there is no email reply-to address present.

These come from 2 scenarios:

1. when there are email templates, and no reply to address – but they
   ignore the checklist
2. when there are no email templates (yet) but they provide anticipated
   volumes for email

At the moment we only auto-check for a reply to address when they have
email templates. And because the question about anticipated volumes
follows the checklist, you'll get a checklist that passes (reply
addresses not required as no templates present) - but your future intent
that differs (reply address IS required because you have anticipated
volumes).

So let’s bring the request for anticipated volumes into the checklist,
that way we can dynamically add the requirement for a reply to address
if they say they will send email but don't have templates yet.

We should begin storing it in the database against the service to stop
people having to re-enter it each time they try to complete the go live
screens.

This also means moving the ‘consent to research question’ along with
the questions about volume, because
- we want people to answer both before going live
- we don’t want to clutter up the summary page by asking questions there
  too
2019-02-27 13:17:28 +00:00
Pea Tyczynska
7da2ed4539 Tell api when mobile or email updated by colleague
So that API can send a confirmation email to the affected user
2019-02-26 16:35:11 +00:00
Pea Tyczynska
d93278f5f0 Ensure that mobile of user not belonging to service cannot be edited 2019-02-26 11:51:56 +00:00
Pea Tyczynska
d60ab838a8 Edit mobile page allows users to proceed without changing mobile number
Also:
- change formatting of mobile number redact characters

- redirect if session empty

- update a test with new mock after rebase
2019-02-26 11:50:56 +00:00
Pea Tyczynska
f7e54b7f5b Change team member's mobile number upon confirmation
Also add edit user mobile number urls to navigation exceptions
2019-02-26 11:50:42 +00:00
Pea Tyczynska
94b78a7649 Confirm change of team member's phone number 2019-02-26 11:50:41 +00:00
Pea Tyczynska
5a59989497 Redirect to mobile number confirmation page 2019-02-26 11:50:41 +00:00
Pea Tyczynska
9d57a81029 Edit mobile number page 2019-02-26 11:50:41 +00:00
Pea Tyczynska
94c4151640 Edit user permissions page shows redacted phone number and Change link
Also make plan for story development
2019-02-26 11:50:17 +00:00
Chris Hill-Scott
882fc7ebab Merge pull request #2810 from alphagov/dont-edit-users-from-other-services
Don’t allow editing of users from other services
2019-02-25 17:30:45 +00:00
Chris Hill-Scott
d82f410325 Don’t allow editing of users from other services
Currently when you load the ‘edit user’ page (which has a URL like
`/service/<service_id>/users/<user_id>`) we check that:
- you belong to the service represented by `service_id`
- you have permission to edit users on this service

We don’t check that:
- the user represented by `user_id` belongs to this service

This means that if you could somehow determine another user’s `user_id`
(which I don’t think is possible if you don’t already have the manage
service permission for that service) then you could:
- edit their permissions on your service (weird, but wouldn’t have any
  effect)
- change their email address (bad)

This commit adds checks to return a `404` any time you’re looking at a
service and trying to do stuff to a user who doesn’t belong to that
service.

We can’t add this check to the API easily because there are still times
that we want to get/modify users outside the context of a service (eg
platform admin pages, or users who have no services).
2019-02-25 17:19:07 +00:00
Katie Smith
62578f5951 Change the format of the user_permissions data that gets sent
The endpoint for setting permissions in api will now be used for both
user permissions and a user's folder permissions, so this changes the
format of the data we pass through.
2019-02-25 16:00:09 +00:00
Chris Hill-Scott
96e02d1c18 Merge pull request #2799 from alphagov/template-nav-order
Put template type navigation in correct order
2019-02-25 15:12:13 +00:00
Chris Hill-Scott
ffaa8cd1a6 Don’t error if email address hasn’t changed
When updating a user’s email address you currently get an validation
error if you save without changing it. Instead it should just obey your
command. And no need for the confirmation step because nothing is
actually changing.
2019-02-25 12:04:07 +00:00
Pea (Malgorzata Tyczynska)
9cd311df02 Merge pull request #2794 from alphagov/edit_user_email
Allow users with "manage_service" permission to edit team members' email addresses
2019-02-25 10:18:34 +00:00
Chris Hill-Scott
8aeb203124 Put template type navigation in correct order
We always talk about the things you can send using Notify as _emails,
text messages and letters_, in that order.

The navigation should reflect this.
2019-02-22 17:19:39 +00:00
Pea Tyczynska
6c406ae5cd Redirect from confirmation page if session empty 2019-02-22 16:13:46 +00:00
Chris Hill-Scott
4b8788aea8 Merge pull request #2793 from alphagov/remove-extra-api-call
Remove redundant API call
2019-02-22 15:04:09 +00:00
Pea Tyczynska
4faf44b5c5 Content changes following consultation with content and design pros :) 2019-02-21 10:54:56 +00:00
Pea Tyczynska
446a17d801 Confirm edit user email changes user email 2019-02-21 10:54:56 +00:00
Pea Tyczynska
3c9c918963 Redirect to confirmation page 2019-02-21 10:53:23 +00:00
Pea Tyczynska
5158377b2e Add a get view and template that enable changing team members email 2019-02-21 10:53:23 +00:00
Alexey Bezhan
261d90ca4d Add edit_folder_permissions permission
Admin part of alphagov/notifications-api#2356
Adds Folder permissions switch to the platform admin part of service
settings page.
2019-02-20 16:45:12 +00:00
Alexey Bezhan
000d6c3a48 Replace platform admin service setting buttons with forms
Most of the existing platform admin buttons on the service settings
page used to issue GET requests to switch service settings. This
means they weren't protected by CSRF. On top of that as our number
of service permissions increases over time a lot of buttons on the
page made it hard to work with.

To fix these issues we replace most of the buttons with rows in the
platform admin settings table. Each setting has a 'Change' link that
leads to a page with an On/Off switch form.

This removes "research mode" switch completely since we're planning
to deprecate it in the future and we don't expect to switch any new
services into research mode at the moment.

Most service permissions are now handled by a shared endpoint that
is parameterized with the permission name. Some permissions that
require some additional logic before they can be toggled (like document
upload, which requires setting a contact address) have separate
initial endpoints that redirect to `set_service_permission`.

"Archive", "Suspend" and "Resume" actions are kept as buttons since
they display a confirmation banner (which is a CSRF-protected form)
and they're not easily represented as an On/Off switch.
2019-02-20 16:45:12 +00:00
Alexey Bezhan
75fd2d4ffc Add a new boolean radios fields and change forms to use it
This adds a new OnOffField class that implements a boolean field
that is rendered as two On / Off radio buttons. This allows us to
avoid comparing 'on' and 'off' string values in the views since
the field takes care of transforming form data into python booleans.

This also adds a form class that can be used for any single On / Off
switch forms (e.g. service permissions).
2019-02-20 16:45:12 +00:00
Chris Hill-Scott
fe57d0adc8 Fix tests 2019-02-20 15:54:00 +00:00
Chris Hill-Scott
dad8d3bff5 Remove redundant API call
The current user already has a list of service IDs. The current user
- is an API call we have to make anyway to render this page
- is usually cached in Redis
2019-02-20 14:54:16 +00:00
Leo Hemsted
c261c41475 Merge pull request #2769 from alphagov/delete-redis-button
Clear redis cache page
2019-02-19 16:20:55 +00:00
Katie Smith
2f4e933b65 Merge pull request #2773 from alphagov/letter-branding-preview
Add preview pane for letter branding
2019-02-19 14:05:21 +00:00
Chris Hill-Scott
032cbf9a17 Flag go live requests from DWP
It’s not enough to check that they’ve signed the agreement. We have to
make sure we inform them every time a service wants to go live.
2019-02-19 11:18:50 +00:00
Katie Smith
d904c7e5c5 Show letter branding preview when selecting a brand
This adds a preview pane which is visible when updating a letter brand.

If JavaScript is enabled, the preview pane shows on the set-letter-branding
page, and submitting the form saves updates the letter brand for a service
immediately. If Javascript is not enabled, there is a separate 'Preview email
branding' page which shows a preview of the brand and has a 'Save' button on it.
2019-02-19 10:44:51 +00:00
Katie Smith
83c10149bd Rename 'email-branding-preview' CSS styles to 'branding-preview'
Renamed since the same styling will be used for previewing letters.
2019-02-19 10:44:51 +00:00
Chris Hill-Scott
61b8e10fc0 Merge pull request #2765 from alphagov/folder-after-delete-template
Return to a template’s folder after deleting it
2019-02-18 13:22:27 +00:00
Leo Hemsted
b062a5a13f make banner green (default) instead of red (dangerous) 2019-02-18 12:09:14 +00:00
Pea (Malgorzata Tyczynska)
cdbbdda730 Merge pull request #2771 from alphagov/update_passowrds_blacklist
Update common passwords blacklist
2019-02-18 11:02:40 +00:00
Pea Tyczynska
3f6e0b6631 Update common passwords blacklist
I did the update following instructions from this commit:
https://github.com/alphagov/notifications-admin/
commit/136662bd309d986a9b7c3e0ee76588612c1ab761

Password repositiories I used were:
darkweb2017-top10000.txt
probable-v2-top12000.txt
twitter-banned.txt
2019-02-15 13:43:46 +00:00
Leo Hemsted
89bfdf27ce add tests 2019-02-15 11:44:09 +00:00
Leo Hemsted
f6367f2278 move (non-api) clients (inc redis) from app/__init__.py to extensions
when clients are defined in app/__init__.py, it increases the chance of 
cyclical imports. By moving module level client singletons out to a 
separate extensions file, we stop cyclical imports, but keep the same 
code flow - the clients are still initialised in `create_app` in 
`__init__.py`.

The redis client in particular is no longer separate - previously redis 
was set up on the `NotifyAdminAPIClient` base class, but now there's one 
singleton in `app.extensions`. This was done so that we can access redis 
from outside of the existing clients.
2019-02-15 11:44:08 +00:00