Commit Graph

9808 Commits

Author SHA1 Message Date
David McDonald
84dedb9cae Merge pull request #3450 from alphagov/non-ascii-metadata
Non ascii metadata
2020-05-19 11:31:26 +01:00
David McDonald
3185505612 Add unit test for LetterMetadata class 2020-05-19 11:20:03 +01:00
Chris Hill-Scott
9306bc3197 Merge pull request #3437 from alphagov/group-uploaded-letters
Group uploaded letters by printing date
2020-05-19 09:49:04 +01:00
David McDonald
387fcfda3f Move recipient decoding into LetterMetadata class
This is for consistency with how we do it for filenames in the previous
commit and moves the decoding into the `LetterMetadata` class for
abstracting this behaviour.

Small refactor of the LetterMetadata class needed to handle None case as
recipient can be None.
2020-05-18 16:13:31 +01:00
David McDonald
7923760345 Ensure pdf letter filename is ascii encoded and decoded
S3 can only handle ascii characters, therefore for filename which could
include non ascii characters, for example a filename with the character
'£' in it, we must encode these using urllib before saving it as s3
metadata. We then also make sure that it comes back decoded when
presenting it to the user.
2020-05-18 16:13:31 +01:00
David McDonald
1fb31a8861 Remove unused args in test
These args are not inputs to the function under test, neither as way of
named arguments or as GET query parameters. I assume this has been
leftover from a previous refactor of behaviour.
2020-05-18 16:13:31 +01:00
David McDonald
ba80d5b7cd Introduce abstraction for s3 metadata
S3 metadata only supports ascii characters. Whenever we save data to it
we need to make sure we encode it to save it and then decode it to
display it again to users. This abstraction will act as the place for
that decoding to happen so the rest of the code in our views doesn't
need to care about the encoding abstraction.
2020-05-18 16:13:31 +01:00
Chris Hill-Scott
6b93de1cb4 Merge pull request #3449 from alphagov/bump-utils-39.2.0
Bump utils to 39.2.0
2020-05-18 12:45:38 +01:00
Chris Hill-Scott
92f90d2ff4 Merge pull request #3445 from alphagov/handle-org-domain-exists-error
Catch error when organisation domain already in use
2020-05-18 12:45:23 +01:00
Chris Hill-Scott
064b1eb05a Bump utils to 39.2.0
This will start loggin Zendesk ticket IDs when people use the support
pages.
2020-05-18 11:08:54 +01:00
Pea Tyczynska
adcd798d88 Catch error when organisation domain already in use
Up till now, when adding new organisation domain, if it was already
in use, we didn't handle the 400 we got back from API. This PR
adds handling for that error.
2020-05-15 17:50:30 +01:00
Chris Hill-Scott
99ab99a232 Merge pull request #3443 from alphagov/international-postage-envelope
Add envelope for international letters
2020-05-15 16:01:20 +01:00
Chris Hill-Scott
a3b690fde6 Test notification page shows international postage
Just to make sure we’re passing the right postage argument through to
the `LetterPreviewTemplate` constructor.
2020-05-15 15:38:58 +01:00
Chris Hill-Scott
73fe640c9c Bump utils to 39.1.0
Allows letters to be previewed with international postage
2020-05-15 15:37:35 +01:00
Chris Hill-Scott
85dbe19611 Add envelope for international letters
International letters aren’t sent by first or second class post. In
keeping with the little touch of skeumorphism, let’s label them with the
commonly recognised marker of international mail instead.
2020-05-15 15:13:31 +01:00
Chris Hill-Scott
336e566d5a Merge pull request #3444 from alphagov/stop-caching-page-count
Don’t cache page count for one off letters
2020-05-15 15:04:14 +01:00
Chris Hill-Scott
2f79ef136d Don’t cache page count for one off letters
Why we did this originally[1]:

> Calculating the number of pages in a letter is quite slow. And the
> send yourself a test pages need to load _fast_. Since filling in
> placeholders is very unlikely to change the number of pages in the
> resultant letter, it’s pretty safe to cache that count, and makes the
> subsequent pages load a lot faster.

However things have changed since then:
- this journey is used for sending real letters, not just test ones
- we’re doing enough letters that even an unlikely discrepancy will (and
  does) happen
- we cache the generation of the PDF now[2], so at least it’s not
  generating the PDF twice, once for the preview and once for the page
  count
- it’s no longer necessary to step through each address placeholder to
  populate a one-off letter, so a little bit slower isn’t so bad

1. e7896f283a
2. c9c6271aa0/app/preview.py (L140)
2020-05-15 13:55:04 +01:00
Tom Byers
9927537d60 Merge pull request #3442 from alphagov/revert-3441-change-checkboxes-to-govuk-frontend
Revert "Change checkboxes to GOVUK frontend"
2020-05-14 17:04:55 +01:00
Tom Byers
f0f461f5c9 Revert "Change checkboxes to GOVUK frontend" 2020-05-14 16:59:34 +01:00
Tom Byers
f893cceec6 Merge pull request #3441 from alphagov/change-checkboxes-to-govuk-frontend
Change checkboxes to GOVUK frontend
2020-05-14 15:23:14 +01:00
Tom Byers
c9420418b3 Fix issues in tests from new fields 2020-05-13 17:37:44 +01:00
Tom Byers
1240ca47a9 Remove all unused checkbox macros and imports 2020-05-13 17:37:44 +01:00
Tom Byers
49ec2d77bb Update all single field checkboxes
Includes adding some code to govukCheckboxesField
to add a single boolean-like option by default, if
there are no choices added.
2020-05-13 17:37:44 +01:00
Tom Byers
33d8171675 Update templates page
Includes:
- changes to the govukCheckboxesField class
  to allow params to be extended at render time
- updates to templates and folders CSS
2020-05-13 17:37:42 +01:00
Tom Byers
0291fbc1cb Update manage folder page 2020-05-13 17:36:40 +01:00
Tom Byers
e030d7d3a1 Update permissions page 2020-05-13 17:36:40 +01:00
Tom Byers
a99ca640e3 Split common checkbox methods off into mixin 2020-05-13 17:36:40 +01:00
Tom Byers
b5f3d1e6e6 Add govukCheckboxField for single checkboxes
Single checkboxes are distinct because:
- they don't need to be wrapped in a `<fieldset>`
- they are a subclass of BooleanField so their
  data is either True or False
2020-05-13 17:36:38 +01:00
Tom Byers
691034ef85 Fix nested checkboxes with single top-level node
Nested checkboxes with a single top-level node
will only have one item in their `items` list.
This is because the other choices are children of
that list item.

This means we need to check the `choices`
attribute, which lists all the checkboxes, to see
if they should be marked as a group (by being
wrapped in a `<fieldset>`) or not.
2020-05-13 16:25:17 +01:00
Tom Byers
efc4aff4fe Add govukCollapsibleNestedCheckboxesField
Includes:
1. changes to make NestedFieldMixin work
  with new fields and CSS for nested checkboxes
2. adds custom version of GOVUK checkboxes
  component to allow us to:
  - add classes to elements currently inaccessible
  - wrap the checkboxes in a list
  - add child checkboxes to each checkbox (making
    tree structures possible through recursion

Change 2. should be pushed upstream to the GOVUK
Design System as a proposal for changes to the
GOVUK Checkboxes component.
2020-05-13 16:20:10 +01:00
Tom Byers
06027b447c Add mixin & field to make collapsible checkboxes
Allows checkboxes to be collapsed so they take up
less space in the page. The collapsed state
includes a live summary tracking which of them are
selected.

Includes changes to the JS for collapsible
checkboxes to make it work with the GOVUK
Checkboxes component HTML.
2020-05-13 16:16:21 +01:00
Tom Byers
012d5767d7 Add govukCheckboxesField
govukCheckboxesField subclasses
SelectMultipleField and overwrites how it renders
HTML to let us use the GOVUK Checkboxes component
while retaining all the functionality of WTForms
fields.

Based on work on github.com/richardjpope/recourse:

https://github.com/richardjpope/recourse/blob/master/recourse/forms.py#L6
2020-05-13 16:13:57 +01:00
Tom Byers
187e23315c Bring in Jinja and Sass for checkboxes component 2020-05-13 16:13:51 +01:00
Chris Hill-Scott
e79ea0e383 Merge pull request #3439 from alphagov/previous-financial-years
Show 2 previous financial years on usage page
2020-05-11 15:15:00 +01:00
Chris Hill-Scott
be86832867 Merge pull request #3438 from alphagov/update-public-support-page
Update content
2020-05-11 15:14:52 +01:00
Chris Hill-Scott
a9998958b7 Link back to uploaded letters page
If you’ve come to look at a notification via the uploaded letters page
then the ‘< back’ link should take you back there, not to the usual
activity page.
2020-05-11 14:30:14 +01:00
Chris Hill-Scott
34f5417844 Group uploaded letters by day of printing
Some teams have started uploading quite a lot of letters (in the
hundreds per week). They’re also uploading CSVs of emails. This means
the uploads page ends up quite jumbled.

This is because:
- there’s just a lot of items to scan through
- conceptually it’s a bit odd to have batches of things displayed
  alongside individual things on the same page

So instead we’re going to start grouping together uploaded letters. This
will be by the date on which we ‘start’ printing them, or in other
words the time at which they can no longer be cancelled.

This feels like a natural grouping, and it matches what we know about
people’s mental models of ‘batches’ and ‘runs’ when talking about
printing.

This grouping will be done in the API, so all this commit need to do is:
- be ready to display this new type of pseudo-job
- link to the page that displays all the uploaded letters for a given
  print day
2020-05-11 14:29:03 +01:00
Chris Hill-Scott
2800b0a0c3 Add page to show all uploaded letters
Because we won’t be showing uploaded letters individually on the uploads
page any more we need a way of listing them. This should be by printing
day, to match how we’re grouping them on the uploads page.

This code reuses the notifications.html template, but flips the
precedence of the filename and recipient because I reckon when you’re
looking at uploads you’re thinking filename-first.
2020-05-11 14:27:43 +01:00
Chris Hill-Scott
8215022725 Show 2 previous financial years on usage page
From a question on cross-government Slack:

> re the Usage tab - currently it shows 3 financial years - last year,
> this year and next year. is it possible to replace the "next year" tab
> with something more useful? its always going to be blank! I was
> thinking it would be good to have 2 financial years ago, 1 financial
> year ago and this financial year.

This seems like a reasonable idea, and is something we’ve talked about
before. The original intention[1] was that seeing your (unchanged) free
allowance for next year would be useful, but that doesn’t really seem to
be a user need.

***

1. See https://github.com/alphagov/notifications-admin/pull/1094
   > so that you can check what your SMS allowance is going to be before
   > you actually get into it
2020-05-07 16:50:19 +01:00
karlchillmaid
f4f9cf3fdd Revert change 2020-05-07 16:42:32 +01:00
karlchillmaid
d5e02df97f Update content
Update descriptions of pages and services. Shorten one of the link titles.
2020-05-07 16:38:13 +01:00
Chris Hill-Scott
77b7e4b8ea Merge pull request #3436 from alphagov/limit-search-50
Don’t show pagination links when searching
2020-05-07 10:09:58 +01:00
Chris Hill-Scott
8655e519aa Change logic around to be clearer
Think this is a clearer expression of what the intent it.
2020-05-07 09:50:03 +01:00
Chris Hill-Scott
6782c21031 Merge pull request #3434 from alphagov/bump-utils-39.0.1
Bump utils to 39.0.1
2020-05-07 08:22:13 +01:00
Chris Hill-Scott
b14e097291 Merge pull request #3433 from alphagov/pyup-scheduled-update-2020-05-04
Scheduled weekly dependency update for week 18
2020-05-07 08:22:05 +01:00
Chris Hill-Scott
aa9ba0f52a Freeze requirements 2020-05-07 08:13:28 +01:00
Chris Hill-Scott
f30187b529 Don’t show pagination links when searching
The search form makes a post request, so that phone numbers and email
addresses don’t show up in logs or browser history.

At most the API will return 50 results, with some pagination links. We
can’t easily give you links to click in the admin app, because links can
only perform get requests.

Because the value of seeing more than 50 results feels quite low (users
will probably make their search more specific before scrolling through
all 50) let’s just show a message saying only the first 50 results are
displayed.
2020-05-06 17:33:19 +01:00
David McDonald
7d9340d76c Merge pull request #3435 from alphagov/fix-letter-job-downloads
Fix bug with letter job CSV downloads
2020-05-06 14:51:32 +01:00
David McDonald
b6935a3c6c Fix bug with letter job CSV downloads
We were throwing an exception when instantiating a LetterImageTemplate
as we weren't giving it all the arguments it needed.

 Now we give it all the correct parameters and add a
test for the method. Ideally we would add a unit test for the flask
route for downloading a letter job CSV (which is currently lacking) but
I did the minimal to be confident I've fixed the bug as I think this
whole code may be fresh for a bit of a rewrite according to Chris.

Original error:
```
File "/Users/davidmcdonald/.virtualenvs/notifications-admin/lib/python3.6/site-packages/notifications_utils/template.py", line 669, in __init__
    raise TypeError('image_url is required')
TypeError: image_url is required
```
2020-05-06 14:44:37 +01:00
Chris Hill-Scott
f7dcd68dbe Bump utils to 39.0.1
Fixes a bug with address validation.
2020-05-06 10:23:54 +01:00