Commit Graph

5463 Commits

Author SHA1 Message Date
Chris Hill-Scott
27f1eeca0b Restrict max width of org and service name
Service names can be quite long. Organisation names can be quite long.
Together they can be very long. This isn’t great because:
- sometimes they overflow the width of the container, which looks broken
- even if they’re not that long they can make the UI look quite
  cluttered

This commit restricts them to widths that should stop the above from
happening. In the case of the organisation name the width has
specifically been chosen to line up with the ¼ and ¾ column grid
used by the navigation.
2019-07-03 15:11:42 +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
44a78d3cd1 Refactor create organisation code into model
So the view layer is cleaner.
2019-07-03 13:34:11 +01:00
Chris Hill-Scott
1c02e611e4 Use same layout as other organisation pages
So it feels consistent from moving from one page to another, rather
than jumping in and out of the platform admin view.
2019-07-03 13:34:11 +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
Chris Hill-Scott
5368ddabbc Fix hard coded organisation name
😳
2019-07-02 16:46:23 +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
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
Rebecca Law
21c23c276f Fix a bug were the user_has_permission.
This is an immediate fix to add the permission checks to the callback page.
However, we have a plan to add a unit test to check for permission introspectively for all routes that have service_id.
2019-06-27 12:20:58 +01:00
Katie Smith
149003c52c Merge pull request #3022 from alphagov/dont-show-org-🍞crumbs-in-trial-mode
Don't show org breadcrumbs for trial mode services
2019-06-26 10:22:18 +01:00
Katie Smith
a9ff4b1d48 Bump utils to add alt text to email branding
Utils 33.0.0 adds alt text to email branding - the HTMLEmailTemplate now
initializes slightly differently as a result (with both `branding_name`
and `branding_text`).
2019-06-25 16:56:45 +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
873272160c Update content on invite page to reflect changes
What org team members can see has changed slightly, so we should update
the hint text accordingly.
2019-06-20 15:38:09 +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
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
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
89cf4904fe Merge pull request #3012 from alphagov/use-new-orgs-and-services-fields
Use new organisation and services fields
2019-06-18 10:51:15 +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
1a3df7039f Fix rendering of scrollable tables
The scrollable tables code styles some of the cells in the target table
by looking for the `table-field-center-aligned` class.

This class was renamed in 0512f40ad3

This commit updates the scrollable tables code to refer to the new
classname, which means that things should line up properly when drawing
the table.
2019-06-17 16:15:34 +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
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
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
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