Commit Graph

2267 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Leo Hemsted
fb0279b820 return free sms allowance in live services csv report 2019-05-31 12:24:18 +01:00
Leo Hemsted
c559ff8c97 refactored live_services_csv
with the aim of making the link between api return values and csv
column headers more apparent
2019-05-31 12:13:34 +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
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
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
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
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
Pea (Malgorzata Tyczynska)
44ddd287b5 Code refactor, details below:
Apply suggestions from code review

Reduce max verification waiting time to 90 seconds

Also minor changes following peer review

Co-Authored-By: Chris Hill-Scott <me@quis.cc>

Use constants for notification status collections on verify reply-to

email address

Use a cleaner way of adding request arguments to url_for()
2019-05-23 15:34:25 +01:00
Pea Tyczynska
200fff6c66 Different back links and form actions on verify page depending if add or change 2019-05-23 15:34:25 +01:00
Pea Tyczynska
e406be3f80 Ensure that when updating reply-to email address old address is replaced
Also fix tests
2019-05-23 15:34:25 +01:00
Pea Tyczynska
6cf9959058 Stop AJAX when success or failure and show form on failure
AJAX requests stop on success or failure, as the waiting page
does not have to referesh any longer.

Also on failure a form that allows user to try again
is shown.
2019-05-23 15:34:25 +01:00
Pea Tyczynska
3251fc4e00 Change content for email reply-to verification journey
Earlier commits used placeholder content while awaiting official
content.
2019-05-23 15:34:24 +01:00
Pea Tyczynska
441c1f441b Verify email address when editing reply-to address
Also fix the tests
2019-05-23 15:34:24 +01:00