Commit Graph

2024 Commits

Author SHA1 Message Date
Chris Hill-Scott
c0c0015dc4 Merge pull request #2448 from alphagov/alphabetical-sort-letter-brandings
Make letter brandings easier to find with sorting and filtering
2018-11-07 13:50:05 +00:00
Chris Hill-Scott
156d38499a Remove integration testing content
This is covered in the new client library documentation. All of the
client libraries now have their documentation published in the new
format.
2018-11-06 17:24:30 +00:00
Chris Hill-Scott
77457c81de Merge pull request #2427 from alphagov/add-notifications-page-test
Add test for the notifications page when there are failed notifications
2018-11-06 16:14:44 +00:00
Chris Hill-Scott
10013a19aa Add live search to letter brandings
Matches what we do for email branding, makes the one you’re lookig for
quicker to find.
2018-11-06 13:08:58 +00:00
Chris Hill-Scott
43988661d6 Sort selected item to the top
When you land on the page it’s good to be able to quickly see what the
currently-set value is, before you change it.

This is unnecessarily hard if the selected item is buried half way down
the page. This commit moves it to the top.
2018-11-06 13:06:48 +00:00
Chris Hill-Scott
c960fef8f8 Always put HM Government at the top of the list
It’s the default, so we should treat it the same way we treat GOV.UK in
the email branding selection.
2018-11-06 13:04:45 +00:00
Chris Hill-Scott
65cc6adabf Sort letter brandings alphabetically
Currently the brandings have non-deterministic sorting, which means
the order changes from page load to page load. This makes it hard to
find the item you’re looking for.

This commit sorts them by the name of the branding, same as for email
brandings.
2018-11-06 13:02:40 +00:00
Chris Hill-Scott
1c9e42f85d Remove update_with_properties method
It’s more Pythonic, and better abstracted from the underlying API to
use keyword arguments instead.
2018-11-05 17:56:11 +00:00
Chris Hill-Scott
318f846630 Move service permission handle inside the model
These helper functions for modifying a service permission were just
floating around loose in the view code.

A much better home for them is on the model. This will also make it
easy to reuse them in other views if we ever need to.
2018-11-05 17:15:52 +00:00
Chris Hill-Scott
39c51dd994 Show all letter pages on the notification page
Sometimes a long placeholder can push stuff onto a new page, so we need
to take the personalisation into account when counting pages.
2018-11-02 14:30:18 +00:00
Chris Hill-Scott
1675e6c8d2 Show error banner for one off letter in trial mode
In trial mode you can’t send letters. But it’s still useful to be able
to build up a letter to see how it work.

Best place to put this error is before someone tries to send a letter
for real.
2018-10-31 14:25:49 +00:00
Chris Hill-Scott
a79dfd1d6e Always show download link for PDF
This feature is useful for people to try the letter thing out and see
how it feels, maybe print one on their own printer before incurring
cost.
2018-10-31 14:22:27 +00:00
Chris Hill-Scott
3a62946ecd Let people send one off letters
We didn’t used to allow this because it wasn’t really possible with the
old DVLA set up and we didn’t think there’s a need.

We think it’s possible now because, even though it’s cumbersome, it’s
better than the manual process.
2018-10-31 12:19:19 +00:00
Chris Hill-Scott
1e2608d2e0 Refactor settings page to use service model
There’s a lot of code in service settings which:
- talks to the API directly through the clients
- passes that information through to the Jinja template

By encapsulating this logic in the service model:
- the Jinja template can access the data directly
- the logic can be reused across multiple methods
2018-10-30 15:07:52 +00:00
Chris Hill-Scott
e04b2b5631 Split models to prevent circular imports
This commit is the first step to disentangling the models from the API
clients. With the models in the same folder as the API clients it makes
it hard to import the API clients within the model without getting a
circular import.

After this commit the user API clients still has this problem, but at
least the service API client doesn’t.
2018-10-30 15:01:36 +00:00
Chris Hill-Scott
9e798506c5 Initialise clients outside the app
This avoids the annoying problem where you can’t import a client unless
the app has already been initialised.
2018-10-30 14:59:24 +00:00
Chris Hill-Scott
e1197c54a5 Don’t allow indexing on service model
Making people use a property is a sure way to make sure they’re spelling
the name of the property correctly, and allows us to easily swap out
properties that call through to the underlying JSON, and properties
which are implemented as methods.
2018-10-30 14:55:01 +00:00
Chris Hill-Scott
780b9bb715 Use cached property from werkzeug.utils
This means we can have a method on the service model which hits the API
(or Redis) but can be called multiple times (within the context of a
request) without making multiple network requests.

It does this by storing the results of the method on the object’s
internal `__dict__` the first time the method is called.
2018-10-30 14:55:01 +00:00
Chris Hill-Scott
1e6b79a546 Put templates on service model
We do a lot of logic around choosing which templates to show. This logic
is all inside one view method.

It makes it cleaner to break this logic up into functions. But this
would mean passing around variables from one function to another.
Putting these methods onto a class (the service model) means that
there’s a place to store this data (rather than having to pass it around
a lot).

Making this code more manageable is important so that when we have
templates and folders it’s easy to encapsulate the logic around
combining the two.
2018-10-30 14:55:00 +00:00
Chris Hill-Scott
d69e8b50cd Only initialised service model once per request
`_get_current_service` is a function which gets called every time
`current_service` is referenced in a view method or Jinja template.

Because the service model was getting initialised inside this function
it was being reconstructed many times in one request. On the service
settings page, for example, it was getting initialised 43 times, adding
about 200ms to the response time.

This commit moves its initialisation to the point where we’re getting
the data from the API, which only happens once per request.
2018-10-30 14:55:00 +00:00
Katie Smith
1ffcbf5e91 Add test for the notifications page when there are failed notifications
We already have tests for the
/services/<service_id>/notifications/<notification_type> page, but these
were not testing the page when there were failed notifications, so this
adds a test for the page in this situation.
2018-10-30 13:15:31 +00:00
Chris Hill-Scott
d5d1f7394d Remove old API key and service ID combo
Once all our users have upgraded to the latest clients they won’t need
this. The latest clients only use the combined key and service ID.

Discuss: when can we safely remove it?
2018-10-30 10:01:37 +00:00
Chris Hill-Scott
f1a9761ea1 Show letters that fail validation as cancelled
At the moment we show precompiled letters that have failed the
validation as having been sent. This is confusing.

We should communicate it as having been cancelled (rather than failed),
with the implication being that Notify has come along and cancelled the
letter before printing it. I think this is conceptually what makes the
most sense.

From the user’s point of view any letters that show up as cancelled
probably need to be fixed and resent, so it makes sense to group them
with the same name.
2018-10-29 12:13:33 +00:00
Chris Hill-Scott
c01d761a3c Show if a letter has been cancelled
At the moment we are manually cancelling letters for people when they
ask us to. Once’s we’ve done this there is no indication that it’s
happened except for the date going red on the list of letters.

This commit adds some error messaging and styling to show when a letter
is cancelled.

Letting people cancel their own letters will be a future enhancement.
2018-10-29 11:51:41 +00:00
Katie Smith
ae79a3ac75 Add platform admin button for edit_folders permission
Added a platform admin button to allow / remove the edit_folders
permission for a service.
2018-10-25 12:09:26 +01:00
Katie Smith
a489e7a26b Stop passing dvla_org_id to template preview
We were passing both dvla_org_id and filename to template-preview
temporarily while we switch to only using filename. Now that
template-preview is set up to use filename, we can stop sending the
dvla_org_id too.
2018-10-23 16:21:18 +01:00
Tom Byers
02ecf1c5b4 Merge pull request #2387 from alphagov/bump-utils-to-3.5.5
Bump utils to 3.5.5
2018-10-19 16:00:56 +01:00
Tom Byers
29c46a27f8 Stop url_for double-encoding .'s in password test
One of the changes this pulls in is encoding of
periods in the token used for new password
requests.

In real-life the resulting URL is build by
concatenating the base url with the token so it
isn't processed further.

The test for new password requests builds the URL
with url_for. This encodes the result returned so
the periods are encoded twice.
2018-10-18 16:59:52 +01:00
Tom Byers
f5014e8352 Fix references to email HTML in tests 2018-10-18 16:59:52 +01:00
Katie Smith
0362265cb6 Pass letter logo filename to template preview
We now pass through `filename` to the Template Preview `/preview.<filetype>'
endpoint in addition to the `dvla_org_id`. Template Preview will be
changed to only use `filename`, and once this has been done, we can change
the code to only pass through `dvla_org_id` instead of passing through
both pieces of information.
2018-10-17 15:17:11 +01:00
Leo Hemsted
c898284c3b fix pdf download link trying to request a page count
It doesn't make sense to get a pdf for only one page - the template
preview app just returns a 400 if you try. So we shouldn't try!
2018-10-15 14:32:10 +01:00
Pea Tyczynska
e6e363ba3f Add antivirus scan to letter validation preview view 2018-10-05 16:27:57 +01:00
Pea Tyczynska
a61393a68e Test letter validation preview flow 2018-10-05 15:46:44 +01:00
Pea Tyczynska
3be129241f Add letter validation preview functionality
- add get/post view
- create a pdf upload form
- add a template where user can upload the file
- check boundaries of the letter by calling template-preview
- display banner messages with boundaries validation result
- display pages of the document, with visible boundaries overlay
if the document did not pass validation, and without overlay
if they do pass validation
2018-10-05 15:46:44 +01:00
Katie Smith
0d842d3700 Pluralize notification type correctly on usage page
This change makes sure that we display '1 letter' instead of '1 letters',
and '1 text message' instead of '1 text messages' on the usage page.
2018-10-03 15:15:19 +01:00
Katie Smith
4188c0297d Display letter postage on the usage page
The monthly letter cost was already broken down by price on the usage
page, but this change adds postage details to the usage page too.
2018-10-03 13:20:44 +01:00
Katie Smith
b1f2b1bc0f Update billing mocks and get_sum_billing_units function
Updated the 'get_sum_billing_units' function to no longer multiply the
billing units by the rate multiplier. The billing_units that come from
notifications-api already consist of the billable_units * rate_multiplier.
The rate_multiplier is also not returned from the api response anymore.

Also updated the billing mocks since these were not mocking the right fields in
the JSON responses from the API billing endpoints, and added the new
'postage' field which will get returned from the monthly-usage endpoint
in notifications-api.
2018-10-03 12:05:49 +01:00
Rebecca Law
2ac5926529 Fix page with missing import and added unit test. 2018-10-02 13:44:55 +01:00
Chris Hill-Scott
0f84ed40e9 Show all pages of a letter on the preview page
We’ve had a support ticket saying:
> Hi, where a letter goes over to two sides, is there a way in the
> 'Preview' screen (or anywhere else) that I can see page two? I can
> see page one OK, but can't work out how to see what's generated on the
> second page.

Whether you’re about to send 1000s of letters – or just want to preview
how one will look – it’s probably useful to be able to see more than
just the first page.
2018-10-01 16:03:06 +01:00
Leo Hemsted
432f1286fe update notifications page to take into account first class! 2018-10-01 11:07:35 +01:00
Leo Hemsted
efab189ae8 update jobs to take into account first class 2018-10-01 11:07:33 +01:00
Leo Hemsted
32f39475d2 remove dupe of get_letter_timings
it was moved from admin to utils a while ago
2018-09-28 15:02:32 +01:00
Chris Hill-Scott
21cec873d0 Stop calling fake_uuid fixture directly
Pytest is deprecating the direct calling of fixtures. One fixture that
we call directly quite a lot is `fake_uuid`. Since it just returns the
value of `sample_uuid()` we can either call that instead (where we need
a fixed value) or generate a new UUID each time (where a fixed value is
not needed).
2018-09-27 14:14:10 +01:00
Chris Hill-Scott
6de0374492 Merge pull request #2327 from alphagov/add-mou-to-checklist
Add line about the data sharing and financial agreement to the checklist
2018-09-26 16:33:13 +01:00
Chris Hill-Scott
3fa877bdd3 Make wording around agreement more straightforward
We think that the next page explains the nuance around service vs
organisation sufficiently well.
2018-09-26 10:37:30 +01:00
Pea (Malgorzata Tyczynska)
6d32d8b756 Merge pull request #2324 from alphagov/state_postage
Display postage on letter notification page
2018-09-25 13:36:34 +01:00
Pea Tyczynska
d982385042 Change wording following content review 2018-09-25 11:05:32 +01:00
Chris Hill-Scott
5dd45da08c Add line about MOU to checklist
2/3 of our incomplete requests to go live are incomplete because the
Data Sharing and Financial Agreement isn’t signed.

We reckon we can be pushier about this by saying it’s ‘incomplete’ where
we know the agreement is signed.

Where the agreement is signed we should confirm this, rather than make
the line disappear. This is so it makes more sense to someone who sees
it as ‘incomplete’, signs it, then comes back to the page.

If we don’t know whether or not the agreement is signed we should wait
until someone has got in touch with us by requesting to go live to
figure it out. So that’s why we’re not showing that line at all.
2018-09-25 10:33:50 +01:00
Chris Hill-Scott
21d29a3090 Fix missing ‘complete’ tag in go live request
This tag was not showing up in the call to the Zendesk API because the
return value of a generator is not included as a member of that
generator (on things `yield`ed from it are).
2018-09-24 17:47:56 +01:00
Chris Hill-Scott
f29cfc0d48 Auto-tag email branding requests 2018-09-24 14:52:31 +01:00