Commit Graph

10934 Commits

Author SHA1 Message Date
Chris Hill-Scott
68e4a2fb89 Merge pull request #3761 from alphagov/extract-formatters
Extract formatters into their own module
2021-01-07 15:22:29 +00:00
Chris Hill-Scott
ac44e6f2ef Remove message count macro file
It’s empty now, we can delete it.
2021-01-07 14:53:12 +00:00
Chris Hill-Scott
24b579418f Replace message count macros with formatters
We prefer formatters now. Removing uses of the aliasing macro lets
remove it entirely.
2021-01-07 14:53:12 +00:00
Chris Hill-Scott
0327ece7ad Replace iteration count macro with formatters
We prefer formatters now. Removing uses of the aliasing macro lets
remove it entirely.
2021-01-07 11:57:30 +00:00
Chris Hill-Scott
4615c0ea3d Replace recipient macros with formatters
We prefer formatters now. Removing uses of the aliasing macro lets
remove it entirely.
2021-01-07 11:57:30 +00:00
Chris Hill-Scott
462294c9d1 Make message and recipient counters formatters
As formatters we can use them in Jinja or Python code.

It also means we don’t need to import them every time we want to use
them – they’re always available in the template context.

For now this doesn’t remove the macros, it just aliases them to the
formatters. This gives us confidence that the formatters are working the
same way the old macros did, and reduces the diff size of each commit.
2021-01-07 11:57:30 +00:00
Chris Hill-Scott
7a95e1618e Extract formatters into their own module
We have lots of functions for converting various types of data into
strings to be displayed to the user somewhere.

This commit collects all these functions into their own module, rather
than having them cluttering up `app/__init__.py` or buried amongst
various other things that have ended up in `app/utils.py`.
2021-01-07 11:57:30 +00:00
Chris Hill-Scott
8595fcf01e Merge pull request #3762 from alphagov/extract-spreadsheet-into-models
Extract Spreadsheet model from app/utils.py
2021-01-07 11:54:49 +00:00
Tom Byers
8f12505330 Merge pull request #3764 from alphagov/give-hidden-input-a-label
Add label for hidden username field
2021-01-07 10:45:08 +00:00
Tom Byers
77c1595826 Add label for hidden username field 2021-01-07 10:34:47 +00:00
Chris Hill-Scott
2c46d023da Extract Spreadsheet model from app/utils.py
`app/utils.py` is a bit of a dumping ground for things we don’t have a
better place for.

We now have a place and structure for storing ‘model’ code (‘model’ in
the model, view, controller (MVC) sense of the word).

This commit moves the spreadsheet model to that place.
2021-01-06 12:31:39 +00:00
Tom Byers
1def62c497 Merge pull request #3760 from alphagov/remove-chrome-form-heuristics-hack
Remove hack for bug in Chrome autocomplete
2021-01-06 10:31:46 +00:00
Tom Byers
d6ffcd3abe Remove hack for bug in Chrome autocomplete
We added an extra, hidden, <input> to our /sign-in
and /register forms to stop Chrome's form
heuristics filling the fields in wrong.

See the commit that added it:

33b15cdec6

This removes it after testing with the following
Chrome/OS combinations and all working without the
hack:

- Chrome 87, Windows 7
- Chrome 86, Windows 7
- Chrome 86, Windows 10
- Chrome 85, Windows 7
- Chrome 80, Windows 10
- Chrome 81, Windows 7
- Chrome 52, Windows 7
- Chrome 68, Windows 7
- Chrome 78, Windows 8.1
- Chrome 86, Windows 8.1

These combinations were based on the most-used
versions recorded in our analytics for the last 3
months.
2021-01-05 17:08:50 +00:00
Tom Byers
ad44e10cb7 Merge pull request #3759 from alphagov/make-big-number-inline
Make big number inline
2021-01-05 16:24:50 +00:00
Tom Byers
72bf9679c6 Remove big_number import from _upcoming template
Think the only use of the macro in this page was
removed in:

https://github.com/alphagov/notifications-admin/pull/3316

...but the import wasn't. This removes it.
2021-01-05 11:44:35 +00:00
Tom Byers
ab8a68ccd1 Remove jobs/_scheduled.html template
From what I can determine, the last include for
this template was removed in:

https://github.com/alphagov/notifications-admin/pull/3338

This assumes that it should have been removed then
so removes it now.
2021-01-05 11:44:35 +00:00
Tom Byers
0237ce7725 Remove big_number import from _inbox partial
It was used for the spark bar but, I think, wasn't
removed when the call to big_number_with_status
was:

https://github.com/alphagov/notifications-admin/pull/3295
2021-01-05 11:44:35 +00:00
Tom Byers
fb442237a1 Remove big_number import from dashboard
It was added in:

https://github.com/alphagov/notifications-admin/pull/734

but neither macro is called so assuming it can be
removed.
2021-01-05 11:44:35 +00:00
Tom Byers
5205743871 Remove big_number import from uploaded-letters
Looks like the import was there when the template
was added but there are no calls to it so removing
it.
2021-01-05 11:44:35 +00:00
Tom Byers
24af978871 Remove big_number import from table component
Looks like this was added in:

4a226a7a29

...and used in the spark_bar_field macro. That
macro was removed in:

89b88ee4cb

..but the import was missed out.
2021-01-05 11:43:57 +00:00
Tom Byers
663df4a4f9 Remove <div>s from big_number text
An accessiblity audit done as part of Notify's
service assessment raised the following problem
with our big_number component.

When you turn CSS off, the sentence in the
component is split onto separate lines.

This was because the number part is wrapped in a
<div> which browsers were interpreting as being a
separate sentence to the label.

So "1 letter", where "letter" is the label, was
seen as:

"1"
"letter"

The accessibility expert consulted on this pointed
out that this would sound confusing for users of
screen readers when moving through the document
sentence by sentence.

These changes:
- make the <div>s into <span>s which are 'phrasing
  content' and so are interpreted as part of the
  same sentence
- change the CSS so the number will still sit
  on top of its label text

The HTML5 spec has a section on how browsers
should arrange text into paragraphs that explains
what was happening in more detail:

https://www.w3.org/TR/html52/dom.html#paragraphs
2021-01-05 11:39:18 +00:00
Chris Hill-Scott
8a751aa5df Merge pull request #3750 from alphagov/validate-broadcast-content-length
Validate length of broadcast content
2021-01-04 11:21:49 +00:00
Chris Hill-Scott
d9ebb0e2a1 Merge pull request #3756 from alphagov/fix-test-failing-after-1730
Fix test that fails after 5:30pm
2021-01-04 10:13:16 +00:00
karlchillmaid
6d8fdb669c Update contact list content (#3464)
* Make the naming of contact lists consistent

* Update content

* Update caption

* Update content

* Update content

* Update content

* Update tests

Co-authored-by: Chris Hill-Scott <me@quis.cc>
2020-12-31 14:03:54 +00:00
Chris Hill-Scott
e7b1834ad4 Merge pull request #3755 from alphagov/remove-inlining-of-images
Remove inlining of images in CSS
2020-12-30 13:36:19 +00:00
Chris Hill-Scott
92d5031d71 Merge pull request #3754 from alphagov/preload-fonts
Tell browsers to preload fonts
2020-12-30 11:09:29 +00:00
Chris Hill-Scott
656f9ca831 Merge pull request #3757 from alphagov/remove-cookie-naming-migration-code
Remove code to migrate cookie names
2020-12-30 11:08:58 +00:00
Chris Hill-Scott
47733bacc8 Remove code to migrate cookie names
We added this code in
https://github.com/alphagov/notifications-admin/pull/3371/files to
account for Flask Login renaming its cookies. We wanted our apps to be
compatible with the old and new names, so people didn’t get logged out
when we rolled out the change.

Now that all the cookies with the old names will have expired (some
weekends have passed since March) we can remove this loop.
2020-12-30 10:19:02 +00:00
Chris Hill-Scott
09eff0fb50 Fix test that fails after 5:30pm
When someone goes to report a problem out of business hours they get
redirected to the page that asks them whether or not its an emergency.
This test was not expecting that redirect. This commit fixes it by
freezing the time around lunchtime on a Wednesday.
2020-12-30 09:50:11 +00:00
Chris Hill-Scott
a2f4abf0d3 Remove inlining of images
In very old browsers it used to be that you could only make 2 concurrent
requests from the same origin.

So base64 encoding of images into CSS was an optimisation that became
popular because it reduced the number of separate requests.

However base64 encoding images has a few disadvantages:
- it increases the size of the image by about 30%
- it increases the size of the CSS file, which is a
  [render blocking resource](https://web.dev/render-blocking-resources/)
  so makes the page appear to load more slowly for the sake of some
  images which, on most pages, never get used
- GZipping things that are already compressed (for example PNG data) is
  very CPU intensive, and might be why Cloudfront sometimes gives up

Removing the inlining of images reduces the size of the CSS we’re
sending to the browser considerably:

–| Before | After | Saving
---|---|---|---
Uncompressed | 198kb | 164kb | 17%
Compressed | 38kb | 23kb | 39%
2020-12-29 18:40:16 +00:00
Chris Hill-Scott
ea124f2886 Tell browsers to preload fonts
When looking at Google’s PageSpeed Insights tool as part of the
compression work I noticed a suggestion that we preload our font files.
The tool suggests this should save about 300ms on first page load time.

***

Our font files are referenced from our CSS. This means that the browser
has to download and parse the CSS before it knows where to find the font
files. This means the requests happen in sequence.

We can make the requests happen in parallel by using a `<link>` tag with
`rel=preload`. This tells the browser to start downloading the fonts
before it’s even started downloading the CSS (the CSS will be the next
thing to start downloading, since it’s the next `<link>` element in the
head of the HTML).

Downloading fonts before things like images is important because once
the font is downloaded it causes the layout to repaint, and shift
everything around. So the page doesn’t feel stable until after the fonts
have loaded.

Google call this [cumulative layout shift](https://web.dev/cls/) which
is a score for how much the page moves around. A lower score means a
better experience (and, less importantly for us, means the page might
rank higher in search results)

We’re only preloading the WOFF2 fonts because only modern browsers
support preload, and these browsers also all support WOFF2.

We set an empty `crossorigin` attribute (which means anonymous-mode)
because the preload request needs to match the origin’s CORS mode. See
https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content#CORS-enabled_fetches
for more details.

We set `as=font` because this helps the browser use the correct content
security policy, and prioritise which requests to make first.
2020-12-29 16:31:11 +00:00
Chris Hill-Scott
810dc03628 Make broadcast template editor expand to fit
It’s fiddly having to scroll within a small textbox to see all the
content. Let’s make the box expand to fit the contents like we do
elsewhere. This was removed by accident when we stopped highlighting
placeholders in broadcast templates in
https://github.com/alphagov/notifications-admin/pull/3672/files
2020-12-29 11:29:57 +00:00
Chris Hill-Scott
8302b2b667 Validate length of broadcast content
Depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/826/files

Adds error messages for when the content of a broadcast template is too
long.

The error message is explicit when this is cause by non-GSM characters.
We may not want to expose this complexity to our users, but it’s useful
for now while we’re testing things out.
2020-12-29 11:29:57 +00:00
Chris Hill-Scott
223003517a Merge pull request #3752 from alphagov/pyup-scheduled-update-2020-12-28
Scheduled weekly dependency update for week 52
2020-12-29 11:05:52 +00:00
Chris Hill-Scott
37038321ba Freeze requirements 2020-12-29 10:46:09 +00:00
pyup-bot
b887480f2e Update notifications-python-client from 5.7.0 to 5.7.1 2020-12-28 13:53:02 +00:00
pyup-bot
80fb52406c Update pytz from 2020.4 to 2020.5 2020-12-28 13:53:02 +00:00
karlchillmaid
e5c34907c3 Merge pull request #3748 from alphagov/use-the-singular-for-royal-mail
Use the singular for Royal Mail
2020-12-23 14:04:34 +00:00
karlchillmaid
f588105aeb Use the singular for Royal Mail
We should use the singular verb form when referring to organisations by name. 

As described in the GOV.UK style guide: https://www.gov.uk/guidance/style-guide/a-to-z-of-gov-uk-style#organisations
2020-12-23 13:56:37 +00:00
karlchillmaid
ada9b0f38d Merge pull request #3746 from alphagov/update-postage-prices
Tell users that postage prices will increase in February.
2020-12-23 11:43:43 +00:00
karlchillmaid
c8f9ef29f0 Update content 2020-12-23 11:12:19 +00:00
karlchillmaid
4ee309fab6 Update rate increase content 2020-12-23 10:58:48 +00:00
karlchillmaid
661b9df643 Revert letter price 2020-12-23 10:30:57 +00:00
karlchillmaid
78135840d4 Update price increases 2020-12-23 10:30:17 +00:00
Chris Hill-Scott
ea611431c4 Merge pull request #3747 from alphagov/accidental-markdown-go-live-ticket
Stop accidental markdown in go live ticket
2020-12-22 17:16:09 +00:00
Chris Hill-Scott
c3515e44cd Stop accidental markdown in go live ticket
In Markdown this is interpreted as a H1:
```
Text
---
```

We can prevent this by adding an extra linebreak, like this:
```
Text

---
```
2020-12-22 17:03:22 +00:00
Chris Hill-Scott
448467435c Merge pull request #3745 from alphagov/reply-to-address-in-ticket
Add email reply to address to go live ticket
2020-12-22 16:41:37 +00:00
karlchillmaid
58eba5c148 Get ready to update product page
Price of a single letter will need to change
2020-12-22 15:43:53 +00:00
karlchillmaid
f11d18c885 Add warning that prices will increase
Add warning that prices will increase – we’re still waiting on confirmation of the price increase and the date.
2020-12-22 15:29:40 +00:00
Tom Byers
aef3cf96ac Merge pull request #3744 from alphagov/revert-test-pre-compressed-asset
Revert "Merge pull request #3738 from alphagov/test-pre-compressed-as…
2020-12-22 14:25:31 +00:00