Commit Graph

7918 Commits

Author SHA1 Message Date
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
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
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
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
Chris Hill-Scott
efb5b16948 Merge pull request #2997 from alphagov/org-settings-platform-admin-only
Make organisation settings platform admin only
2019-06-04 11:25:56 +01:00
Chris Hill-Scott
9f3cc8baf1 Only show ‘back to service’ for active services
When a user deletes their service we take them to the ‘Choose service’
page. Like other non-service-specific pages this has a link to the last
service you were looking at. But in this specific case the last service
you were looking at is the one you’ve just deleted. Which means the link
is confusing because:
- you thought the thing was ‘gone’
- we’ve secretly renamed it to ‘_archived Example service name’

So this commit hides the link in this specific case.
2019-06-04 09:50:02 +01:00
Chris Hill-Scott
954f43ae48 Let users archive their own trial mode services
At the moment we have a blanket rule that users can’t archive their own
services, to prevent someone accidentally deleting a real live service,
because that would be Very Bad.

But the tickets we get from users asking us to delete services are for
services they set up when they were just trying out Notify. There’s not
much harm in letting users delete these services, the consequences of
doing so are much lower than those of deleting a live service. And it
should mean fewer support tickets for us to deal with.
2019-06-04 09:45:51 +01:00
Chris Hill-Scott
5e9f70c62c Merge pull request #2999 from alphagov/bump-utils
Bump utils to 32.0.1
2019-06-04 09:39:54 +01:00
Katie Smith
53fb9197e3 Bump utils to 32.0.1
This updates requirements and brings in the change to preserve trailing semicolons
on URLs.
2019-06-03 16:14:46 +01:00
Chris Hill-Scott
6d03bfee96 Merge pull request #2992 from alphagov/extend-whitelist-to-organisations
Look in organisation for whitelisted domains
2019-06-03 14:16:47 +01:00
Chris Hill-Scott
ee5212941c Add back links to organisation settings pages
They’re nice.
2019-06-03 14:12:12 +01:00
Chris Hill-Scott
6fc1635266 Rename some of the settings
This reflects the language we use for these things when talking about
them amongst ourselves.
2019-06-03 14:12:12 +01:00
Chris Hill-Scott
80e6c1654b Make organisation settings one table
There’s no longer a difference between regular settings and platform
admin settings – it’s all platform admin.
2019-06-03 14:12:12 +01:00
Chris Hill-Scott
3b22216a68 Remove redundant decorators
`@user_has_permissions` is overridden by @user_is_platform_admin – it
doesn’t make sense to have them used together.
2019-06-03 14:12:12 +01:00
Chris Hill-Scott
647daa6ca4 Make organisation settings platform admin only
At the moment the only setting that a normal organisation team member
can change is the name of the organisation is its name. And we don’t
even want them to be able to change this. So this commit hides the
settings page entirely for non-platform-admin users.
2019-06-03 14:12:11 +01:00
Chris Hill-Scott
34f0c83690 Don’t bother with YAML syntax
Since this file doesn’t have any complicated data types, plain text with
one line per domain is fine.
2019-06-03 13:21:29 +01:00
Chris Hill-Scott
d9f885344c Remove domains that belong to an organisation
If a domain is already in our organisation list then we no longer need
to manually update it here. As part of this process I went and
proactively added some organisations, so I could remove more of them
from this file. I only did this where I could clearly determine from the
domain or a suppot ticket what the organisation was.
2019-06-03 13:21:29 +01:00
Chris Hill-Scott
5e76dbb6a7 Cache known domains in Redis
The domains lookup is a bit slow because it’s serialising all the
organisations in the database. Since we’re putting this in the sign up
flow it should feel snappy, so lets cache just the domain bit of it in
Redis.
2019-06-03 11:41:14 +01:00
Chris Hill-Scott
8835486d4e Look in organisation for whitelisted domains
At the moment we have to update a YAML file and deploy the change to get
a new domain whitelisted.

We already have a thing for adding new domains – the organisation stuff.

This commit extends the validation to look in the `domains` table on the
API if it can’t find anything in the YAML whitelist.

This has the advantage of:
- not having to deploy code to whitelist a new domain
- forcing us to create new organisations as they come along, so that
  users’ services automatically get allocated to the organisation once
  their domain is whitelisted
2019-06-03 11:41:13 +01:00
Pea (Malgorzata Tyczynska)
c55c2a2f56 Merge pull request #2993 from alphagov/fix_test_send_placeholders
Fix error where sending test message flow skipped first placeholder
2019-05-30 15:57:13 +01:00
Pea Tyczynska
bafa4e345b Change assertion for consistency 2019-05-30 15:45:17 +01:00
Chris Hill-Scott
3deff78a75 Merge pull request #2988 from alphagov/loading-spacing
Remove spacing tweak on loading indicator
2019-05-30 13:54:32 +01:00
Leo Hemsted
3a1282d03f Merge pull request #2987 from alphagov/org-trial-services
move trial mode services from org dashboard to separate page
2019-05-30 11:19:17 +01:00
Pea Tyczynska
8286e86a9e Harmonise behaviour of Change reply-to email address
So it acts the same on inital edit and after verification failed.
And also so it does not allow to untick default address in the
latter situation.
2019-05-29 17:02:57 +01:00
Pea Tyczynska
4905be510f Update tests so they work with the fix 2019-05-29 16:56:55 +01:00
Pea Tyczynska
21ab8638b9 Fix error where sending test message flow skipped first placeholder
first way round and then collected placeholders again. Now the flow
collects all placeholders in one round.

Also fix the back link for step-1 for test flow so it goes back
to choosing recipient number

Also move operators around following flake8's advice :)
2019-05-29 16:56:55 +01:00
Pea (Malgorzata Tyczynska)
378fec281a Merge pull request #2974 from alphagov/check_reply_to_address
Verify email reply-to address
2019-05-29 10:36:18 +01:00
Pea (Malgorzata Tyczynska)
a0c21baca9 Apply suggestions from code review
Co-Authored-By: Chris Hill-Scott <me@quis.cc>
2019-05-28 17:20:30 +01:00
Leo Hemsted
4375c3d151 move to model based code layout 2019-05-28 16:46:12 +01:00
Leo Hemsted
9795f2b838 move trial mode services from org dashboard to separate page
the new page is platform admin only, and also has search built in
also, split test_organisation_invites into two files
2019-05-28 16:17:29 +01:00
Chris Hill-Scott
a65450b118 Merge pull request #2990 from alphagov/fidejoseph-patch-1
Update email_domains.yml
2019-05-28 15:37:17 +01:00
fidejoseph
39271d9e6a Update email_domains.yml
Adding Scottish Qualifications Authority
2019-05-28 10:31:30 +01:00
Pea Tyczynska
4fd9e91993 Do not verify email when updated email address did not change 2019-05-24 11:22:20 +01:00
Pea Tyczynska
934bcb919f Reduce timeout to 45 seconds following analysis by Chris H-S:
"Failure is slower than success. So the longer a notification
takes to get a status, the more likely it is for that status
to be a failure anyway. This increases dramatically after 45 seconds.
The percentage of emails that go to delivered in less than 90 seconds
is 98.92%. To get to 99% we’d need to increase the timeout
to 178 seconds (3 minutes). We could still get 98.7% of notifications
by dropping the timeout to 45 seconds, and improve the experience
for notifications that are likely to fail by returning an error more quickly."
2019-05-23 15:34:25 +01:00