Commit Graph

180 Commits

Author SHA1 Message Date
Chris Hill-Scott
12b7c5d5e8 Remove notify_go_live_incomplete tag
The new taxonomy doesn't have a `notify_go_live_incomplete` tag. We
replaced this with `notify_go_live_incomplete_mou` because the only way
users can submit an incomplete request is if they do not agree to the
MOU.

These are the incomplete tags:

- `notify_go_live_incomplete_mou`
- `notify_go_live_incomplete_reply_to`
- `notify_go_live_incomplete_shared_email`
- `notify_go_live_incomplete_templates`

Of those, only the first one is applied automatically.
2019-11-19 16:42:25 +00:00
Chris Hill-Scott
7a5d301104 Update Zendesk tags to reflect new taxonomy
Requests to go live and email branding requests come through to Zendesk
with tags attached automatically.

With the revised taxonomy some of these tags need to be updated, as
summarised in this spreadsheet.

In addition, `notify_action` tag has to be added in each of those cases.

Old|New
---|---
`notify_request_to_go_live_complete`|`notify_go_live_complete`
`notify_request_to_go_live_incomplete`|`notify_go_live_incomplete`
`notify_action_add_branding`|`notify_branding`
`notify_request_to_go_live_incomplete_mou`|`notify_go_live_incomplete_mou`
`notify_request_to_go_live`|`notify_go_live`

– https://docs.google.com/spreadsheets/d/1o5ATsFsVK8Qpj7x8QvxX-SfEuBZ75028GEySVcdBFYU/edit#gid=0https://www.pivotaltracker.com/story/show/169842970
2019-11-19 15:46:29 +00:00
Chris Hill-Scott
554a852e2d Don’t return UUID objects from the UUID convertor
Because it means you often have to cast to string in your application
code just to get your tests passing.

The method being monkey patched is originally defined here: b81aa0f18c/src/werkzeug/routing.py (L1272)
2019-11-07 13:46:24 +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
Chris Hill-Scott
7eb547a9e8 Put upload letters button on jobs page
This is going to become the one true ‘Uploads’ page, so it need the
sticky footer that takes users into the new upload letters journey.
2019-10-25 12:48:30 +01:00
Chris Hill-Scott
600e3affc1 Show user names for events without API changes
This commit introduces a slightly hacky way of putting usernames against
events, given that the API only returns user IDs.

It does so without:
- making changes to the API
- making a pages that could potentially fire off dozens of API calls (ie
  one per user)

This comes with the limitation that it can only get names for those team
members who are still in the team. Otherwise it will say ‘Unknown’.

In the future the API should probably return the name and email address
for the user who initiated the event, and whether that user was acting
in a platform admin capacity.
2019-10-23 13:15:41 +01:00
Chris Hill-Scott
d93ebd99d3 Refactor history off the service model
Directly referencing the `ModelList` instances will let us more easily
make choices at the view layer about which kinds of events to show, and
is one less layer of indirection to jump through.
2019-10-23 13:08:06 +01:00
Chris Hill-Scott
59b4d60c91 Munge stuff into a consistent event data type
We store our audit history in two ways:

  1. A list of versions of a service
  2. A list of events to do with API keys

In the future there could be auditing data which we want to display that
is stored in other formats (for example the event table).

This commit adds some objects which wrap around the different types of
auditing data, and expose a consistent interface to them. This
architecture will let us:
- write clean code in the presentation layer to display these events on
  a page
- add more types of events in the future by subclassing the `Event` data
  type, without having to rewrite anything in the presentation layer
2019-10-23 13:02:11 +01:00
Chris Hill-Scott
7c2ecfa094 Use service model for history
Rather than have the view layer interact directly with the API client.
This will let us add extra transformation in the model layer at some
point.
2019-10-21 16:29:06 +01:00
Chris Hill-Scott
78e57dbff9 Clear service cache for when updating org branding
Updating an organisation’s branding might now also update the branding
of services associated to that organisation. This is similar to how
updating an organisation’s type can update the organisation type for its
services.

In the latter case we already make sure to clear the cached version of
these services which is held in Redis.

This commit does the same clearing of the caches when updating an
organisation’s branding (and does a bit of refactoring to do so without
duplication of code.)
2019-10-03 12:10:53 +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
077dc194c6 Tell people to change their branding
In some cases it’s not appropriate for teams to have GOV.UK branding.
But they all start with it by default, if we can’t make a better guess.
We should be more explicit about this to reduce the number of teams
sending emails with the wrong branding.
2019-09-16 11:21:28 +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
Chris Hill-Scott
29a0611e42 Refactor organisation branding into model
This is the same way we handle lazy-loading the branding in the service
model.
2019-09-16 11:02:34 +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
daeefefeaa Let GP surgeries create their own organisations
We have a bunch of GP surgeries who want to go live. They don’t
automatically assigned to organisations. So this means a lot of back and
forth to get these organisations set up, and then the service has to
re-request to go live, and… it’s painful.

Instead, let’s let GPs create their own organisations, by confirming the
name of their organisation before going on to letting them accept the
agreement.
2019-09-05 15:01:12 +01:00
Chris Hill-Scott
d41effe8ce Allow GPs to click through to the agreement
We want GPs to be able to accept the agreement online. But at the moment
they don’t get automatically assigned to organisations. So we need to
let them enter the agreement accepting journey even if they don’t have
an organisation set up.
2019-09-05 14:46:02 +01:00
Chris Hill-Scott
c9a32c7327 Remove duplication of org type lookup
There’s a couple of places where we’re looking up the label for the type
of organisation.

Having this repeated in multiple places means it’s more likely we forget
to update one of these places when making a change.

This commit looks up from the tuple in the organisation model, which is
where other code references this stuff from. This is only possible now
that we don’t have duplicate keys (ie GP practice doesn’t share a key
any more).
2019-08-28 15:36:09 +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
Chris Hill-Scott
45ae5b1782 Merge pull request #3041 from alphagov/delete-letter-contact
Let users delete letter contact blocks
2019-07-24 10:47:48 +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
44d5dc44d3 Allow deleting default letter contact blocks
It’s possible to delete default letter contact blocks because there is a
fallback – having a blank letter contact block. This is different to SMS
senders and reply to addresses.

For this to make sense it also means:
- adding the ‘blank’ letter contact block to the list of letter contact
  blocks
- having a way of setting the default back to being blank
2019-07-22 11:57:11 +01:00
Pea Tyczynska
eae1ccf607 Refactor following review 2019-07-19 16:10:55 +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
Chris Hill-Scott
2e78981648 Merge pull request #3054 from alphagov/remove-old-agreement-pages
Remove the user-specific agreement pages
2019-07-17 13:07:39 +01:00
Pea Tyczynska
77d281f44f Introduce new org types 2019-07-16 17:00:26 +01:00
Katie Smith
b6ebbe6f67 Add organisation_type property to Service model
This will return the organisation_type of the service's organisation (if
there is one), or the organisation_type of the service if not.
2019-07-16 11:36:19 +01:00
Chris Hill-Scott
a256b9c33a Remove the user-specific agreement pages
We used to give users the right version of the agreement by guessing
their organisation from their email address.

Now we do it by looking at the organisation of the service they’re
looking at.

In other words, users should only be downloading the agreement as part
of the go live journey, not outside it. This is because we think that
users will get confused if they download the agreement and:
- find there’s nowhere to physically sign it
- think that accepting the agreement is all they need to do to go live

Maintaining two paths to download the agreement also makes the code more
complicated, and makes it harder to update the content on these pages.
2019-07-15 15:25:05 +01:00
Chris Hill-Scott
04144b55be Merge pull request #3044 from alphagov/count-orgs-and-services-on-choose
Add count of organisations and live services for platform admin user
2019-07-09 14:53:17 +01:00
Chris Hill-Scott
cca19df73c Stop JSONModel hiding attribute errors
`__getattr__` is called whenever an attribute error is raised.

This means that if something deep inside a property on a model raised
an attribute error, that error would be caught by `__getattr__`, which
would then raise an exception that looked like the property itself
didn’t exist. Very confusing.

The solution seems to be to override `__getattribute__` instead, which
handles _all_ attributes, not just those that aren’t explicitly defined.
We then only intervene if the desired attribute is one of the
`ALLOWED_PROPERTIES`, otherwise falling through to the built in methods
of the underlying `object`.
2019-07-09 14:06:49 +01:00
Chris Hill-Scott
c11a43cbc4 Update live services count when service is counted
If we change our mind and decide whether a service should/should not be
counted in the list of live services then we should also drop the cache
which stores the count of how many live services there are.
2019-07-08 14:46:34 +01:00
Chris Hill-Scott
e731dd70d1 Use chevrons not slashes to separate folders
It looks weird to have two different visual treatments for showing a
navigable hierarchy.

I reckon losing the slash won’t make things less folder like – Windows
for example uses chevrons as foler separators.
2019-07-03 15:17:36 +01:00
Chris Hill-Scott
44a78d3cd1 Refactor create organisation code into model
So the view layer is cleaner.
2019-07-03 13:34:11 +01:00
Rebecca Law
3fc072af09 Merge pull request #3037 from alphagov/fix-org-invite
Fix a bug with inviting existing users to an organisation.
2019-06-28 11:06:52 +01:00
Chris Hill-Scott
6026ce3f8d Refactor model to put add_to… methods on user
An invited user can’t be added to an organisation or service, only a
real user can. So the methods to do this should be on the user model,
and take the details of the invite as arguments.
2019-06-27 15:48:29 +01:00
Rebecca Law
d344bc7006 Fix a bug with inviting existing users to an organisation.
The method to add the user to the organisation was missing the user id. This PR fixes that.
2019-06-27 15:34:23 +01:00
Chris Hill-Scott
305920733a Merge pull request #3019 from alphagov/sign-online
Allow online acceptance of the contract/memorandum of understanding
2019-06-27 15:26:41 +01:00
Chris Hill-Scott
3968d5b766 Allow org team members to see team and usage
Organisation team members will be ultimately interested in the detailed
usage of each service, but shouldn't necessarily have access to the
personal data of that services users.

So we should allow these organisation team members to navigate to live
services usage page from the organisation page. They may need to contact
the team so they should also be able to view the team members page.

So they'll then see just usage and team members pages.

If they are actually a team member of the service they're viewing, then
they'll see the full range of options as usual.

This commit implement the above by adding an extra flag to the
`user.has_permissions` decorator which allows certain pages to be marked
as viewable by an organisation user. The default (for all other existing
pages) is that organisation users don’t have permission.
2019-06-20 15:37:52 +01:00
Chris Hill-Scott
31afd65e71 Refactor permissions checking to use methods
It’s a bit more concise to use these methods, rather than access the
lists directly.

And because it’s easier to read it will make later refactoring less
bothersome.
2019-06-20 14:32:08 +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
290e111810 Stop making multiple API calls to get_organisation
The count of live services is coming back from the `/organisations`
response. We don’t need to get each organisation individually now.
2019-06-17 16:14:25 +01:00
Chris Hill-Scott
913095fe60 Wrap a model around list of all organisations 2019-06-17 16:00:59 +01:00
Chris Hill-Scott
0aea038d51 Use new fields for getting orgs and services
Uses https://github.com/alphagov/notifications-api/pull/2539 to reduce
the number of API calls we make.
2019-06-17 15:56:59 +01:00
Chris Hill-Scott
cf3e9302a0 Merge pull request #3015 from alphagov/optional-platform-admin
add option to suppress platform admin temporarily
2019-06-17 10:00:45 +01:00
Chris Hill-Scott
faaa812379 Merge pull request #3013 from alphagov/org-client-refactor
Wrap get org methods in class method on model
2019-06-14 16:56:02 +01:00
Leo Hemsted
c724f84c23 change wording of platform admin toggle to positive rather than negative
CHS Approved Wording 👍

also rename suppress_platform_admin -> disable_platform_admin_view in
the backend, as suppress is a kinda weird word.
2019-06-14 15:13:56 +01:00
Leo Hemsted
7b02cb72c6 add option to suppress platform admin temporarily
so that platform admins (us) can view pages as regular users do easily.
Simply adds a flag in the session cookie that overrides the actual
platform admin flag on the user model if set. This way it's safe, since
this only downgrades existing functionality, so if someone managed to
alter it they could only get less permissions, not more.

You can change this value from the user profile page if either:

* you're a platform admin
* the flag is set (to any value) on the cookie.

This slightly weird check means that we don't check the underlying
`user._platform_admin` flag anywhere in the code, even when toggling
the suppression.
2019-06-14 11:59:12 +01:00
Chris Hill-Scott
c7325576d6 Merge pull request #3008 from alphagov/new-choose-service
Split choose service page into live services and trial mode services
2019-06-13 17:01:19 +01:00
Chris Hill-Scott
04f6bd8132 Wrap get org methods in class method on model
This means the service and user models have to import one fewer thing,
and matches what we’re doing with the `from_id` class method.
2019-06-13 14:23:02 +01:00