Commit Graph

7981 Commits

Author SHA1 Message Date
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
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
588e151d09 Merge pull request #3011 from alphagov/quis-patch-1
Remove debugging short circuit
2019-06-13 17:01:12 +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
Chris Hill-Scott
edba0c7f5f Rename confusing property
It’s more about the multiple different types of things they can see, not
just that there are multiple things.
2019-06-13 13:47:29 +01:00
Chris Hill-Scott
53f5ebdd48 Add some visual differentiation for null info
We use light grey for stuff like ‘not set’ elsewhere. This knocks it
back a bit so the actual information on the page is more prominent.
2019-06-13 13:47:29 +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
451fadb1b3 Hide H1 for grid layout
With the `<h2>`s on this page it’s fairly explicit what the page is
listing, so user doesn’t need the context provided by the `<h1>`.
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
e31570e93d Refactor to use .belongs_to methods
The view code shouldn’t need to know the internals of a service’s data
structure; the idea of having a service model is to abstract this kind
of thing.
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
71dc650db6 Make user model return a service model, not JSON
This makes it:
- nicer, by having access to sensibly named things like
  `Service.trial_mode` instead of `service['restricted']`.
- less likely to write Jinja code like `service.trail_mode`, which would
  fail silently if `service` was a dictionary
2019-06-13 13:47:28 +01:00
Chris Hill-Scott
062f42b769 Rename all_services property on user
For consistency with `.organisations`/`.organisation_ids`.

`.services` returns a list of semi-rich dictionaries for each service.

`.service_ids` returns service IDs only.
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
63ba3a6f30 Put organisations on the user model
As in other places, putting a model layer between the view and the API
client makes the code cleaner and clearer.
2019-06-13 13:42:11 +01:00
Chris Hill-Scott
88e36d6841 Move some methods from the API client to the model
They make more sense being on the model, and it doesn’t make any sense
to duplicate them.
2019-06-13 13:42:10 +01:00
Chris Hill-Scott
b233e3ca24 List live services if no organisations
If the user doesn’t belong to any organisations then the only live
services they can see are the ones they directly have access to. So
let’s list these above the user’s trial mode services (because they’re
more important).
2019-06-13 13:42:10 +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
Chris Hill-Scott
2f4d9a1a46 Remove debugging short circuit
Circumventing this exception was only added for debugging purposes.
2019-06-12 13:33:58 +01:00
Chris Hill-Scott
cb63d44c08 Merge pull request #3009 from alphagov/no-back-link-just-sent
Hide back link when you’ve just sent a message
2019-06-11 13:31:04 +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
b93a72092b Merge pull request #3007 from alphagov/fix-invites
Fix inviting existing users
2019-06-06 17:40:42 +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
Katie Smith
486976a091 Merge pull request #2985 from alphagov/archive-user
Allow a user to be archived
2019-06-06 13:08:17 +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
73b4aa4d85 Refactor event handler code 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
d44dad2817 Merge pull request #3004 from alphagov/empty-usage
Only show the en dash if month is totally empty
2019-06-05 16:53:50 +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
Pea (Malgorzata Tyczynska)
ecfd20b9cf Merge pull request #3002 from alphagov/email_as_placeholder_test_flow
Recipient email/number works as placeholder in test send one off journey
2019-06-05 15:44:17 +01:00
Chris Hill-Scott
954aecf160 Remove defaults from JSONModel
We’re not setting them anywhere any more.
2019-06-05 14:55:43 +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
Chris Hill-Scott
e43f78a72d Don’t implement separate __getitem__ for invited users
It can inherit now because both `User.__init__` and
`InvitedUser.__init__` have the same method signature.
2019-06-05 14:54:48 +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