Commit Graph

2572 Commits

Author SHA1 Message Date
Chris Hill-Scott
c9f76e427d Fix tests 2019-07-10 10:18:30 +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
6d5f542a88 Count of orgs and live services for platform admin
This makes it consistent that an option which contains more options has
a hint about how many options it contains.

Also adds a formatter to get us ready for 1,000 services 🎉
2019-07-08 12:31:31 +01:00
Chris Hill-Scott
c709d7668e Merge pull request #3024 from alphagov/style-org-breadcrumb
Adjust type and spacing to accommodate organisation breadcrumb
2019-07-04 16:38:47 +01:00
Pea Tyczynska
0118787a56 Can't cancel letter job if job not processed yet
Also add more tests for showing or not the cancel those letters link

Also check if all notifications already in database

Upgrade delete button text logic to handle more cases

Also corrections following review
2019-07-04 14:44:22 +01:00
Pea Tyczynska
4a679a6583 Letter job can't be cancelled if already printed
Non-cancellable letter statuses mean that it's too late to cancel a job
2019-07-04 14:44:21 +01:00
Pea Tyczynska
ab953896ab User can cancel a letter job - happy path 2019-07-04 14:43:37 +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
96bd0a55b2 Move the breadcrumb inside the link
Putting the background image on the preceding breadcrumb item will allow
us to replace it with a pseudo element in a subsequent commit.
2019-07-03 15:17:34 +01:00
Chris Hill-Scott
a91f0e0515 Merge pull request #3038 from alphagov/add-more-info-when-creating-org
Require more information when creating organisations
2019-07-03 14:10:44 +01:00
Chris Hill-Scott
08bc893ddf Redirect to new organisation after creation
The thing you want to do after creating an org is probably set some
domains or default branding, so let’s take you to the page where you can
do that.
2019-07-03 13:34:12 +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
b620b677d3 Have permissions decorators check user signed in
Rather than force us to write the decorators in a specific order let’s
just have one decorator call the other. This should make fewer lines of
code, and fewer annoying test failures. It also means that the same way
of raising a `401` (through the `current_app` method) is used
everywhere.
2019-07-03 09:54:35 +01:00
Chris Hill-Scott
3da9e84ece Enforce order of permissions decorators
At the moment we mostly have `user_has_permissions` execute first. It
shouldn’t matter, but it feels right for us to check that a user is
logged in before we check their permissions to a service. Otherwise a
malicious user could (maybe) check if a service ID belongs to a real
service, and go on to do something malicious with that information.

This commit adds some extra test code to enforce that the order is
always the same.

N.B. decorators in Python execute from closest to furthest (from the
line on which the function is defined).
2019-07-03 09:54:17 +01:00
Chris Hill-Scott
91f2da8b68 Ensure all service route have permission decorators
We accidentally miss these sometimes. This code adds a test which
inspects the code to automatically check that any function which:
- handles a route
- accepts a service_id

For each function it checks that each of these routes have the
permissions decorator we’d expect.

Most of the introspection/AST code is adapted from here:
https://mvdwoord.github.io/exploration/2017/08/18/ast_explore.html
2019-07-03 09:47:20 +01:00
Chris Hill-Scott
1f02a2d3ab Determine agreement by service not user’s org
A user might not have a guessable organisation type, even if the service
they’re working on does have an organisation set. This can happen for
users with @nhs.net email addresses, for example.
2019-07-02 17:22:36 +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
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
fa5f3945bf Direct users to contact us if crown status unknown
If we’re not sure whether a user belongs to a crown organisation or not
we want to fix that before.

This is a last-ditch fallback because we shouldn’t be adding new
organisations without also setting their crown status.
2019-06-27 14:46:58 +01:00
Katie Smith
f3ff7ee84d Don't show org breadcrumbs for trial mode services
Platform admin users can still see the organisation breadcrumbs for
trial mode services, but others uses can only see organisation
breadcrumbs for live services.
2019-06-20 16:58:53 +01:00
Chris Hill-Scott
e6733d7e24 Link to usage, not dashboard
Organisation team members only have access to the dashboard if they’re
also a member of that service.

They always have access to the usage page, so let’s link there instead.
2019-06-20 15:38:16 +01:00
Chris Hill-Scott
afedf431e0 Link to all services from organisation
Because a member of the organisation can now see some pages for any live
service they should be able to click into each one.
2019-06-20 15:38:02 +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
Katie Smith
5f2c869a1c Show organisation breadcrumbs
Added a breadcrumb link to a service's organisation to the
withnav_template. This will only show if a service has an organisation
and the current user is also a member of that org, or the current user
is a platform admin user.

Also removed a couple of unused fixtures from the client_request
fixture.
2019-06-20 12:11:13 +01:00
Chris Hill-Scott
02566c4381 Merge pull request #3018 from alphagov/fixes-for-check-spreadsheet-page
Fixes for check spreadsheet page
2019-06-19 13:32:28 +01:00
Chris Hill-Scott
174064c30a Relabel checklist step to ‘accept’
There’s no signature involved any more.
2019-06-19 13:21:20 +01:00
Chris Hill-Scott
b4c81f8960 Add progressive enhancement
When someone selects that they are accepting the agreement on behalf of
someone else then they need to provide that person’s details. Otherwise
they shouldn’t care about these extra fields.

This commit uses the progressive disclosure pattern from the GOV.UK
Frontend Toolkit to hide the additional fields unless someone selects
the relevant radio button.
2019-06-19 13:19:51 +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
772066164c Only print the id attribute if it’s a string
If it’s something weird like an instance of a Python object let’s ignore
it (else we get invalid HTML like
`id='<notifications_utils.columns.Cell object at 0x1126f4e80>'`).
2019-06-17 17:09:45 +01:00
Chris Hill-Scott
14225027d2 Fix incorrect argument name in test
This test wasn’t checking the redirect because the argument name was
missing the leading underscore.
2019-06-17 16:53:18 +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
e6304fe10d Add count of live services to organisation list
This is useful information that we might as well return now we have it.
2019-06-17 16:04:48 +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
da29d722f9 Merge pull request #2983 from alphagov/add-js-tests-for-fullscreen-table
Add js tests for fullscreen table
2019-06-17 10:00:53 +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
082349e68e Merge pull request #3014 from alphagov/cache-organisations
Cache organisations, not just domains in Redis
2019-06-14 16:55:53 +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
Leo Hemsted
d752a6335f make sure tests all populate the platform admin field
it's always returned by the API
2019-06-14 15:14:00 +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
8f9ade7a8b Cache organisations, not just domains in Redis
This should make the ‘All organisations’ page load a lil’ bit quicker.
Still worth caching the domains separately so the response is smaller
when we only care about domains. This is because the code that uses the
domains is part of the sign up flow, so it’s really important that it’s
snappy.
2019-06-14 11:20:19 +01:00
Chris Hill-Scott
14a3420fbe Split list of user’s services into live and trial
This gives us as platform admin users a bit more context when we’re
looking at a user’s profile.
2019-06-13 13:47:29 +01:00
Chris Hill-Scott
8b6b8c6165 Add a grid layout to the choose services page
This allows us to split the page into sections without over-using bold
fonts. And it means that when the user clicks into a service from this
page the column layout stays the same 1/4 – 3/4, rather than jumping
about so much.
2019-06-13 13:47:28 +01:00
Chris Hill-Scott
1b395c04f3 Go straight into org if no trial mode services
You might still belong to some services, but because they’re live
they’re all in your organisation.
2019-06-13 13:47:28 +01:00
Chris Hill-Scott
2f711b52ea Refactor choose service page into macros
This makes it easier to see the logic controlling which services are
shown where because the repetitive loops have been factored out.
2019-06-13 13:47:27 +01:00