Commit Graph

435 Commits

Author SHA1 Message Date
Pea Tyczynska
21e6d994b9 Validate service and organisation name 2019-11-20 13:31:01 +00:00
David McDonald
4ca4cef1b3 Merge pull request #3144 from alphagov/choose-postage
Choose postage
2019-11-05 10:14:40 +00:00
David McDonald
9ba1dbfffa Do not show postage stamp for letter preview 2019-11-01 10:47:42 +00:00
David McDonald
fdf74572b9 Add radio button and convert from to WTForm 2019-11-01 10:47:42 +00:00
Chris Hill-Scott
fcc84ac514 Do extra code style checks with flake8-bugbear
Flake8 Bugbear checks for some extra things that aren’t code style
errors, but are likely to introduce bugs or unexpected behaviour. A
good example is having mutable default function arguments, which get
shared between every call to the function and therefore mutating a value
in one place can unexpectedly cause it to change in another.

This commit enables all the extra warnings provided by Flake8 Bugbear,
except for the line length one (because we already lint for that
separately).

It disables:
- _B003: Assigning to os.environ_ because I don’t really understand this
- _B306: BaseException.message is removed in Python 3_ because I think
  our exceptions have a custom structure that means the `.message`
  attribute is still present
2019-11-01 10:43:01 +00:00
Katie Smith
3b3f74bbf0 Use the new error messages when uploading a letter
We now use the pattern of showing a box at the top of the page with the
error. The error message has a heading and can have additional details.
Error messages and the invalid pages get stored in the S3 metadata.
2019-10-21 08:37:55 +01:00
Chris Hill-Scott
7f033efc28 Fix email branding request page with only textbox
If there aren’t a range of options (normally presented as radio buttons)
to show the user on the email branding request page then we just show
the textbox. But we were still doing form validation on the radio
buttons, even though the user couldn’t see them to click them. This
stopped the user from being able to submit the form.

This commit fixes the problem by, in this specific case, pre-ticking the
‘Something else’ radio button.
2019-10-09 16:42:30 +01:00
karlchillmaid
a2455abda4 Replace can't with cannot 2019-09-23 13:20:24 +01:00
Chris Hill-Scott
56772533e6 Replace negative contraction with Cannot
In accordance with style guide
2019-09-18 14:21:25 +01:00
Chris Hill-Scott
20f857753a Use constants for organisation type
This reduces the chances of making a typo, because doing so will raise
an exception rather than fail silently.
2019-09-16 11:33:50 +01:00
Chris Hill-Scott
afcdedf598 Allow elaboration when ‘something else’ is chosen
Letting people input a bit of free text should reduce the amount of back
and forth we have to do over support tickets when setting up someone’s
branding.

If something else is the only option then we don’t show the radio button
at all and have just the free text input on the page (not behind a
progressive disclosure).
2019-09-16 11:18:22 +01:00
Chris Hill-Scott
6d0d10e8de Only show relevant choices of email branding
Users who work in local government can’t have GOV.UK branding on their
emails. And only those working for Companies House (for example) can
request the Companies House branding.

This commit adds:
- new choices of email branding, which offer the name of the branding,
  rather than the style
- logic to filter this list to only the applicable options, based on
  what we know about the user, service and organisation

This is a change from the previous approach which put the onus on users
to figure out the style of branding they wanted, when we might already
know that a lot of the options weren’t available to them, or would be
inconsistent with the branding of other services in their organisation.
2019-09-16 11:03:52 +01:00
Katie Smith
c577416866 Add letter upload form which redirects to blank preview page
Added a form to upload a single letter. Currently this only uses the
form to validate that a file is submitted and that the file is a PDF. If
either of these validations fail, the form will display an error.
Otherwise, we redirect to a new preview page which just has the filename
as the heading for now.
2019-09-12 09:54:36 +01:00
Chris Hill-Scott
8b8893ed1d Let NHS Trusts and CCGs choose own organisation
All we do via support is ask which organisation they work for and
manually assign their service to it. This commit makes that process self
service.

We think we have all the trusts and clinical commissioning groups
loaded into the database now.

This will make the go live process smoother for these teams.
2019-09-06 16:26:51 +01:00
Chris Hill-Scott
e0ab43f988 Let GPs nominate service name
Most GP practice services are named after the practice, which is the
organisation.

So rather than make people re-type the name of their organisation (and
potentially make a typo) let’s just let them say ‘yes, that’s the name
of my organisation’.
2019-09-05 15:01:12 +01:00
Chris Hill-Scott
38c2b32fa8 Add ‘GP’ as an organisation type
Although their allowances are the same as what we call `nhs_local` it
makes more sense to store them separately because:

- we already present them as two separate choices to the user
- we may want to handle them differently in the future, eg in terms of
  what branding choices are available to them

Once the API is updated we can start passing in this new value from
the admin app.
2019-08-28 15:36:09 +01:00
Chris Hill-Scott
efabf0e87d Refactor to avoid redefinition of org types
We’re defining the list of org types in a few different places. This
makes it more likely we’ll forget to update one of these places, thereby
introducing a bug.

This commit moves the definition to be on the organisation model, which
feels like a sensible enough place for it.
2019-08-28 15:36:08 +01:00
Pea Tyczynska
a906552c25 Require data on search by name form
This lets us build leaner views when using this form.
2019-08-15 12:41:51 +01:00
Katie Smith
9dc13f1d8e Add new report to show monthly notification stats for each service
This report will be used by the engagement team. There is a form to give
a start and end date for the report, and the form is then downloaded
as a CSV file when the form is submitted.
2019-07-23 11:32:28 +01:00
Pea (Malgorzata Tyczynska)
1bd5ff1dfc Merge pull request #3057 from alphagov/new_org_types_part_1
Introduce new org types
2019-07-22 15:56:31 +01:00
Chris Hill-Scott
06bb0e997e Merge pull request #3056 from alphagov/spellcheck-email
Set autocomplete and spellcheck attributes on email field
2019-07-22 12:09:14 +01:00
Pea Tyczynska
c8ed608c9a Only show nhs radios if user has nhs domain email
Also split local NHS into two groups following designer advice
on readability.
2019-07-18 17:07:42 +01:00
karlchillmaid
1de8ffc010 Update agreement form content 2019-07-18 15:58:24 +01:00
karlchillmaid
95f9215546 Update agreement form content
Update agreement form content
2019-07-18 10:46:01 +01:00
Chris Hill-Scott
88242c31d1 Don’t spellcheck email addresses
The GOV.UK Design System recommends:
> setting the spellcheck attribute to false so that browsers do not
> spellcheck the email address
2019-07-16 17:14:49 +01:00
Pea Tyczynska
77d281f44f Introduce new org types 2019-07-16 17:00:26 +01:00
Katie Smith
53214937a8 Stop allowing the service org type to be changed
The service organisation type will either be the same as the org type of
the service's organisation or will be set by a user when creating a new
service. This removes the ability to change it from the platform admin
settings table.
2019-07-16 11:36:19 +01:00
karlchillmaid
c4c8a34c46 Update 'reply-to email address' 2019-07-09 16:47:11 +01:00
Chris Hill-Scott
959dd6ac38 Make one method for comma-formatting numbers
We were doing this a few different ways in different places.
2019-07-08 14:46:34 +01:00
Chris Hill-Scott
a6b3561cf7 Don’t create new organisations with no crown status
We need the crown status set so that we can let them accept the
agreement online.
2019-07-03 13:34:11 +01:00
Chris Hill-Scott
0916b2ba6b Require more information when creating organisations
Currently we set not-very-useful defaults for organisation type and
crown status when creating an organisation. This commit adds two field
to the form (in addition to the existing name field) to explicitly ask
for:
- organisation type
- crown status

We need these for all organisations before we can make any of their
services live.

This commit also records any new organisation as not having accepted the
data sharing and financial agreement, because if we don’t know about the
organisation already then they definitely won’t have signed it.
2019-07-03 13:34:11 +01:00
Chris Hill-Scott
0728d9b4fb Add validation for agreement accepted on behalf of
If the user has selected that they are accepting the agreement on behalf
of someone else then we need to make the they provide that person’s
details.

If they’ve selected that they are accepting the agreement themselves
then we have to ignore what they might have put in the ‘on behalf of
boxes’ (for example if they filled them out but then changed their
mind).
2019-06-19 13:19:50 +01:00
Chris Hill-Scott
eb3f9aad2a Add pages to let users accept the agreement online
At the moment, the process for accepting the data sharing and financial
agreement is:

1. download a pdf
* print it out
* get someone to sign it
* scan it
* email it back to us
* we rename the file and save it in Google Drive
* we then update the organisation to say the MOU is signed
* sometimes we also:
 * print it out and get it counter-signed
 * scan it again
 * email it back to the service

Let's not do that any more.

When the first service for an organisation that doesn't have the
agreement in place is in the process of going live, then they should
be able to accept the agreement online as part of the go live flow. This
commit adds the pages that let someone do that.

Where the checklist shows the agreement as **[not completed]** then
they can follow a link where they can download it (as happens now).
From here, they should then also be able to provide some info to accept
it. The info that we need is:

**Version** – because we version the agreements occasionally, we need to
know which version they are accepting.  It may not be the latest one if
they downloaded it a while ago and it took time to be signed off

**Who is accepting the agreement** – this will often be someone in the
finance team, and not necessarily a team member, so we should let the
person either accept as themselves, or on behalf of someone else. If
it's on behalf of someone else we need to the name and email address of
that person so we have that on record. Obvs if it's them accepting it
themselves, we have that already (so we just store their user ID and
not their name or email address).

We then replay the collected info back in a sort of legally
binding kind of way pulling in the organisation name too. The wording
we’re using is inspired by what GOV.UK Pay have. Then there’s a big
green button they can click to accept the agreement, which stores their
user ID and and timestamp.
2019-06-19 13:14:02 +01:00
Chris Hill-Scott
08fe6865bd Merge pull request #2944 from alphagov/allow-replace-revoked-key
Allow replacing a revoked key
2019-06-14 16:55:45 +01:00
Chris Hill-Scott
628e344b36 Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
                         API (returns JSON)
                                  ⬇
          API client (returns a built in type, usually `dict`)
                                  ⬇
          Model (returns an instance, eg of type `Service`)
                                  ⬇
                         View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:

```
                         API (returns JSON)
                                  ⬇
    API client (returns a model, of type `User`, `InvitedUser`, etc)
                                  ⬇
                         View (returns HTML)
```

This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.

It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.

For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-06-05 11:13:41 +01:00
Chris Hill-Scott
81b299428f Add tests for editing folder permissions for platform admin users 2019-05-17 11:03:41 +01:00
Katie Smith
5be6b41195 Allow Welsh characters in SMS
- This brings in the latest version of notifications-utils which
allows Welsh characters in SMS templates.
- Updated the pricing page to show the new prices for SMS with certain
Welsh characters
2019-05-15 14:20:49 +01:00
Katie Smith
da971b2da7 Allow custom notes when service goes live
This adds an option on the organisation settings page to add
'request_to_go_live_notes'. When a service belonging to this
organisation requests to go live, any go live notes for the
organisation will be added to the Zendesk ticket in the 'Agreement
signed' section.
2019-05-14 14:24:26 +01:00
Katie Smith
d689b031a2 Allow non-gov email addresses to be changed to gov email addresses
When a user's email address is updated, we not allowing it to be changed
to a non-government email address. We now allow a non-gov email address
to be changed to another non-gov email address. Government email
addresses still cannot be changed to non-government email addresses.

Also fixes the link in the error message on the ChangeEmailAddress form -
this was being escaped before.
2019-04-25 10:36:04 +01:00
Katie Smith
33aa16661e Delete unused form 2019-04-25 10:36:04 +01:00
Chris Hill-Scott
470b8a2912 Remove domains from branding forms
We’re deprecating storing the domain as text on a branding in favour of
a database relationship between branding and organisation.

We need to do this now in order to remove the validation on these fields
(which depends on the data in `domains.yml`)
2019-04-12 15:23:07 +01:00
Chris Hill-Scott
f1126c8cbb Say ‘team members’ not ‘users’ for permissions
This is consistent with the language we use elsewhere.

Also removes the colon (it’s considered implicit in a form label).
2019-04-01 17:23:16 +01:00
Chris Hill-Scott
8fb576e60a Allow excluding services from live services count
Adds a front end for:
https://github.com/alphagov/notifications-api/pull/2417

> Sometimes we have to make a few services for what really is one
> service, for example GOV.UK Pay and GOV.UK Pay Direct Debit. We also
> have our own test services which aren’t included in the count of live
> services. We currently count these as one service by not including
> them in the beta partners spreadsheet.
2019-03-25 15:46:35 +00:00
Chris Hill-Scott
50bb20ad32 Allow up to 20 domains per organisation
The most we have in the spreadsheet is 18
2019-03-22 16:27:30 +00:00
Chris Hill-Scott
936883bf7b Allow editing of an organisation’s details
Adds a user interface for updating all the columns added in
https://github.com/alphagov/notifications-api/pull/2368

Sorry for the mega commit 😓
2019-03-22 14:23:24 +00:00
Pea Tyczynska
86d8464fa2 Show all users in folder viewing permissions, correct users checked 2019-03-18 17:58:53 +00:00
Pea Tyczynska
1ab36dd026 Show checkboxes for users with permission to view the managed folder 2019-03-15 14:13:27 +00:00
Alexey Bezhan
a2389fe2ca Make folder permissions form label more descriptive 2019-03-05 11:45:50 +00:00
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