Commit Graph

2546 Commits

Author SHA1 Message Date
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
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
Chris Hill-Scott
f774a10e3a Only show live services without an organisation
In reality we shouldn’t have any live services that don’t have an
organisation. But we probably do locally, in preview, etc., and we
shouldn’t lose a way of accessing them.
2019-06-13 13:47:27 +01:00
Chris Hill-Scott
3be1f79cf9 Add count of live services to organisations
This makes it clear that these are something different to the trial
mode services, in that they are a container of multiple things.
2019-06-13 13:42:11 +01:00
Chris Hill-Scott
722d1f0af4 Hide organisation services
We think users fall into three buckets:

Has access to a few live services, no organisations
--
In this case they user will just see the list of live services they have
access to – pretty straightforward.

Has access to all live services, plus the organisation
--
Conceptually the live services are part of the organisation, whereas the
trial mode ones aren’t. So it makes sense to go through the organisation
to see the live services. If we listed the live services on the choose
service page then we’d be confusingly duplicating them on the
organisation page.

Has access to the organisation, but no services
--
The user doesn’t have direct access to their organisation’s services, so
they need to go to via the organisation page to change service.

For both of the latter we’ll be providing a quick breadcrumb route back
into the organisation, so most of the time they won’t need to use the
choose service page at all.
2019-06-13 13:42:11 +01:00
Chris Hill-Scott
1ca0dfacf7 List all trial mode services
At the moment the service list doesn’t disambiguate between live and
trial mode services. This makes it hard to tell which of the things are
important and which aren’t.

The first step towards making this page clearer is to list trial mode
services separately.
2019-06-13 13:42:10 +01:00
Chris Hill-Scott
3511f8ad5b Move organisations out of platform admin area
It’s annoying having to go through the slow-to-load platform admin index
page to get to organisations. And it makes more sense for them to be
in the same place as other organisations and services that you can see.
2019-06-13 13:42:10 +01:00
Tom Byers
1a5d40312a Move window mock functions into helper class 2019-06-12 16:03:35 +01:00
Tom Byers
1082a37750 Update call out to sticky JS, with test for it 2019-06-12 16:03:26 +01:00
Tom Byers
0131f0c1b1 Move setup/teardown out of tests 2019-06-12 16:03:18 +01:00
Tom Byers
435334ba9c Add tests for full-screen table module 2019-06-12 16:03:09 +01:00
Chris Hill-Scott
c6b21ab022 Hide back link when you’ve just sent a message
Changed this yesterday. Changing it again now because I think it’s
confusing.

There’s really no going ‘back’ once you’ve sent a message – you can’t
undo it. If you want to get back to the template you used, well, that
link is in the page.

This commit changes the back link logic so it only appears when you’ve
navigated to a notification, not when you’ve just sent it.
2019-06-07 16:16:13 +01:00
Chris Hill-Scott
6130004b0c Fix inviting existing users
The API needs the id of the user, not the id of the invite.

The problem with the tests is that the update mock returned a different
user ID than the user it was being passed. So the tests didn’t catch
this.
2019-06-06 17:24:48 +01:00
Chris Hill-Scott
f2303ff20a Merge pull request #3005 from alphagov/fix-back-links-tour
Fix back links in tour
2019-06-06 16:43:02 +01:00
Chris Hill-Scott
8034d7ecc2 Merge pull request #3006 from alphagov/fix-placeholder-collection-order-send-test
Fix order of steps in send/send test journeys
2019-06-06 16:42:42 +01:00
Chris Hill-Scott
7cc8fcfb2d Fix order of steps in send/send test journeys
This fixes the bug where if you have three placeholders:
> ((one)) ((two)) ((three))

The first one you are asked to fill in is `((three))` (ie
`template.placeholders[-1]`).

This reintroduces a bug where if you use the ‘Use my phone number’ link
you skip straight to filling in `((two))` and can never proceed because
you’re never given the chance to fill in `((one))`. This commit also
fixes that bug.
2019-06-06 12:24:02 +01:00
Chris Hill-Scott
48eb698713 Fix back link on ‘sent’ page in tour
If the user wants to go back from here they need to be sent back to the
start of entering the placeholders, because we won’t have their previous
personalisation in the session still

I think the back link on this page was introduced by accident. But it’s
good to still have it on this page, because it keeps consistency with
the previous pages.
2019-06-06 12:00:23 +01:00
Katie Smith
a6f5abbf7e Only show archive user link for active users 2019-06-06 11:50:28 +01:00
Chris Hill-Scott
62fb71966b Add back links to all steps of tour 2019-06-06 11:31:50 +01:00
Katie Smith
f57f8641ad Add an event if a user is archived
This adds a new type of event, 'archive_user', which stores the id of
the archived user and the id of the user who is doing the archiving.
2019-06-06 09:56:16 +01:00
Katie Smith
00bb7a0ea0 Add page to archive user
Users can only be archived by Platform Admin from the user page
(/users/<user_id>). This removes them from all services and orgs and
updates their details.
2019-06-06 09:56:16 +01:00
Chris Hill-Scott
7b3d522070 Merge pull request #2991 from alphagov/user-api-client-return-json
Make user API client return JSON, not a model
2019-06-06 09:51:52 +01:00
Chris Hill-Scott
0c2aa0824b Merge pull request #2995 from alphagov/new-email-reply-to
Update email_reply_to.html
2019-06-05 16:53:58 +01:00
Chris Hill-Scott
944a7d302c Fix logic for showing and hiding checkbox
The ‘make this default’ checkbox should be shown, except when:
- the user is adding their first email reply to address (because the
  first one has to be the default)
- they’re editing the existing default (because they can’t change it
  to be not default)
2019-06-05 16:41:06 +01:00
Chris Hill-Scott
f34a252e72 Remove defaults from User model
the api always returns exactly:
```
id
name
email_address
auth_type
current_session_id
failed_login_count
logged_in_at
mobile_number
organisations
password_changed_at
permissions
platform_admin
services
state
```

it does this through `models.py::User.serialize` – there is an old
Marshmallow `user_schema` in `schemas.py` but this isn’t used for
dumping return data, only parsing the json in the create user rest
endpoint.

This means we can rely on these keys always being in the dictionary.
2019-06-05 14:55:43 +01:00
Leo Hemsted
9922752640 Merge pull request #2996 from alphagov/free-sms-fragment-report
Show free sms fragments in live services billing report
2019-06-05 14:46:49 +01:00
Chris Hill-Scott
bd9acb1310 Make invited user model inherit from JSONModel
This is more consistent, and less fiddly that always having to call it
with a dictionary expansion.
2019-06-05 14:39:02 +01:00
Chris Hill-Scott
a1b846e159 Move user model test to model folder
This is consistent with where tests for other models are kept.
2019-06-05 11:13:41 +01:00