Commit Graph

7951 Commits

Author SHA1 Message Date
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
Chris Hill-Scott
f8fb2d3c8f Make Users model inherit from sequence
This gives the same behaviour as you’d expect inheriting from `list`.
However because `list` is written with a lot of optimisations it’s
unpredictable to inherit from.

Python provides a series of abstract base classes that you can inherit
from instead.

Further reading:
1. https://docs.python.org/3.4/library/collections.abc.html#collections.abc.Sequence
2. https://treyhunner.com/2019/04/why-you-shouldnt-inherit-from-list-and-dict-in-python/
2019-06-05 12:50:43 +01:00
Chris Hill-Scott
8492496c34 Make permissions a setter
This is better because it reuses native constructs of the language,
rather than half reimplementing them ourselves.
2019-06-05 11:13:42 +01:00
Chris Hill-Scott
0be359b678 Use JSONModel for user model
Our other models inherit from `JSONModel`, rather than manually doing
lookups of the JSON in the `__init__` method. This commit changes the
user model to work in the same way.

I had to add a new concept (`DEFAULTS`) to account for some properties
not always being present in the (mocked) JSON. In reality it might be
that the API does always return these values. This should be looked at
in future work, to see which defaults can be safely removed. At least
now they:
- do not mean any changes are needed to the existing tests
- are explicitly separated from the attributes that we do expect to
  always be in the JSON response
2019-06-05 11:13:41 +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
Chris Hill-Scott
628e344b36 Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
                         API (returns JSON)
                                  ⬇
          API client (returns a built in type, usually `dict`)
                                  ⬇
          Model (returns an instance, eg of type `Service`)
                                  ⬇
                         View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:

```
                         API (returns JSON)
                                  ⬇
    API client (returns a model, of type `User`, `InvitedUser`, etc)
                                  ⬇
                         View (returns HTML)
```

This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.

It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.

For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-06-05 11:13:41 +01:00
Chris Hill-Scott
d66cabf300 Merge pull request #3003 from alphagov/fix-org-nav
Fix organisation nav
2019-06-04 16:48:44 +01:00
Chris Hill-Scott
6b494a2b86 Only show the en dash if month is totally empty
This code wasn’t taking into account that you might have sent letters
in the month.

The dash is only there to space out months which don’t have any usage
in them.
2019-06-04 16:26:00 +01:00
Chris Hill-Scott
41c50f2397 Say trial _mode_ services 2019-06-04 16:21:37 +01:00
Chris Hill-Scott
813ed8c856 Make settings link platform admin only 2019-06-04 16:20:44 +01:00
Pea Tyczynska
f34b2ea038 Recipient email/number works as placeholder in test send one off jourrney 2019-06-04 16:12:09 +01:00
Chris Hill-Scott
d9df3171a0 Make verb consistently ‘Change’ 2019-06-04 15:41:12 +01:00
Chris Hill-Scott
3905f3b4fd Merge pull request #3001 from alphagov/how-to-pay
Make ‘How to pay’ its own page under pricing
2019-06-04 15:01:09 +01:00
Chris Hill-Scott
aebbd13498 Update app/templates/views/service-settings/email-reply-to/add.html 2019-06-04 14:17:46 +01:00
Chris Hill-Scott
040b00e39c Make content of validate and error pages consistent
Makes all three pages have:
- the same hint text
- balanced spacing
- a checkbox for controlling whether the address is the default
2019-06-04 14:17:45 +01:00
Pete Herlihy
ceb75f5a32 Tidy up trailing spaces. 2019-06-04 13:56:03 +01:00
Pete Herlihy
dd02df6cc1 Removed extra warning about personal email accounts
This is now on the add page, rather than the hub.
2019-06-04 13:56:03 +01:00
Pete Herlihy
3c4ff774b9 Added hint about reply to email address to add emphasis 2019-06-04 13:56:03 +01:00
fidejoseph
3b014f3e60 Update email_reply_to.html
Adding an extra line to see if this can reduce the number of personal reply-to emails being submitted
2019-06-04 13:56:03 +01:00
Chris Hill-Scott
00bf77621f Don’t use plus to refer to VAT
Got some advice from the content community:

> I don't think we have a style on this - it doesn't really come up on
> GOV.UK mainstream.
>
> In your example, I'd go with something like 'less than £250 before
> VAT' or 'less than £250 (not including VAT)' to make it as clear as
> possible. Would that work?

I’ve gone with ’less than £250 (before VAT)’. I noticed that elsewhere
we’ve said ‘Each message costs 1.58 pence (plus VAT)’ so that feels
fairly consistent.
2019-06-04 13:50:01 +01:00
Chris Hill-Scott
1ea604a740 Make ‘Trial mode’ page highlight features nav item 2019-06-04 13:49:54 +01:00
Chris Hill-Scott
05dd4bf9a7 Make column widths consistent with other pages
Pages within a service use a 2/8, 5/8, 1/8 grid.

The content pages use a 1/4, 3/4 grid, for consistency with the product
page template.

But I feel like the internal consistency is more important, and it feels
weird for the main content column to jump about.
2019-06-04 13:49:47 +01:00
Chris Hill-Scott
399eff7215 Make a reusable ‘content’ template
This is for static content pages and makes sure they always have the
right column widths and sub navigation.
2019-06-04 13:49:39 +01:00
Chris Hill-Scott
77469e0710 Add left-hand navigation to pricing pages
So that you don’t have to use the footer navigation to switch between
these related pages. Matches the template we use for organising
features-related content.
2019-06-04 13:49:31 +01:00
Chris Hill-Scott
8f6089c62f Remove ‘How to pay’ section from pricing page
It’s on its own page now.
2019-06-04 13:49:24 +01:00
Chris Hill-Scott
22299ea97d Add ‘How to pay’ page
Content from https://docs.google.com/document/d/1uIFW8c7Vk0-FQ-d8H1FmNZLHKn_tOXWg5oUL8bbcZzw/edit?ts=5ced1ae4#
2019-06-04 13:49:16 +01:00
Chris Hill-Scott
20c4719d07 Move pricing template into own folder
So we can keep thing organised when adding more pricing-related content.
2019-06-04 13:04:24 +01:00
Chris Hill-Scott
bbbda5f968 Merge pull request #2994 from alphagov/let-trial-mode-services-be-archived
Let users archive their own trial mode services
2019-06-04 13:03:41 +01:00
Chris Hill-Scott
a6c2b5a99c Merge pull request #3000 from alphagov/gaap-rip
Update blog link in light of ‘Government as a Platform’ being retired
2019-06-04 13:03:29 +01:00
Chris Hill-Scott
99f917896a Update blog link in light of ‘Government as a Platform’ being retired
> we will be closing this blog and putting all future Government as a Platform (GaaP) news on the GDS blog.

– https://governmentasaplatform.blog.gov.uk/2019/04/18/this-blog-is-now-closed/
2019-06-04 11:35:14 +01:00