Commit Graph

3635 Commits

Author SHA1 Message Date
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
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
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
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
d50eb11c7a Add email reply to address to go live ticket
It’s one of the things we check when someone makes a request to go live,
and putting it in the ticket means we don’t have to take the extra step
of clicking into the settings.

Also added some line breaks to chunk things up a bit more clearly.
2020-12-22 14:02:33 +00:00
Tom Byers
e80b02d2c9 Merge pull request #3742 from alphagov/fix-for-file-input-in-safari
Fix for file input bug in safari
2020-12-17 14:24:25 +00:00
Tom Byers
55a4ca6579 Remove set-to-string conversion from upload code
Also changes the allowed_spreadsheet_file_extensions
variable to allowed_file_extensions for
consistency.
2020-12-17 13:04:27 +00:00
Tom Byers
97bc2817bc Merge pull request #3731 from alphagov/add-govuk-radios-5
Add GOVUK radios [part 5]
2020-12-16 14:48:49 +00:00
Tom Byers
51cc2a5296 Set accepted files for branding upload 2020-12-16 14:48:10 +00:00
Tom Byers
1096d1f707 Set accepted files for contact list upload 2020-12-16 14:48:10 +00:00
Tom Byers
fb1ac8bc42 Set accepted files for letter upload 2020-12-16 14:48:10 +00:00
Tom Byers
b8f8d743d5 Set accepted files for job spreadsheet upload 2020-12-16 14:48:10 +00:00
Tom Byers
88e85ea01c Update liveSearch JS tests and test helpers
Includes a change to make these tests use the
getRadioGroup helper to reduce duplication across
the tests. This also makes a few changes to the
helper so it can produce the HTML required.
2020-12-15 12:08:09 +00:00
Tom Byers
4e47b62aa3 Update previewPane JS and JS radios test helpers
The previewPane JS used selectors that targeted
the old form of radios HTML.

The JS tests also contained selectors like this
and fragments of HTML, used for fixtures, modelled
on the old radios HTML.
2020-12-15 12:08:09 +00:00
Chris Hill-Scott
d1ab09db05 Merge pull request #3739 from alphagov/refactor-user-live-services
Remove separate function for live service check
2020-12-14 15:22:10 +00:00
Katie Smith
57189f57e4 Add form validation for max service and org name
There was a recent error in the logs because a service tried to change
its name to one exceeding 255 characters (which is a limit on the
database field). We can easily catch these errors on the form, so that
the user doesn't see an error page.
2020-12-11 11:33:34 +00:00
Katie Smith
4e96f82c67 Fix client_request.post in test
The `post` method of the `client_request` fixture has an argument called
`_data`. There were a few places where we had used an argument of `data`
instead by mistake.
2020-12-11 11:33:34 +00:00
Chris Hill-Scott
5027be31fc Remove separate function for live service check
When we get a support ticket we need to check whether a user has any
live services.

We have a method for this on the user model now, so we don’t need a
separate function in the feedback code.

It wasn’t very well tested so I’ve adapted the old tests from the
feedback view to work against the method on the user model too.
2020-12-10 15:43:45 +00:00
Tom Byers
b1d0d216e0 Convert radios on add org page
Changes OrganisationCrownStatusForm.crown_status.

This also effects NewOrganisationForm, which
inherits from OrganisationCrownStatusForm.

Because of that this commit also updates the
template used for the edit org crown status page,
which uses NewOrganisationForm for its form.
2020-12-10 10:19:50 +00:00
Tom Byers
0cdbb850aa Convert radios in edit org type page (basic)
Changes the OrganisationTypeField class used by
OrganisationOrganisationTypeForm.organisation_type

OrganisationTypeField is also used by the forms in
/add-service:
- CreateServiceForm
- CreateNhsServiceForm

Because of that, this commit also includes changes
to the template for that route.

Note: this also moves where OrganisationTypeField
appears in app/main/forms.py so it can use
GovukRadiosField.
2020-12-10 10:19:49 +00:00
Tom Byers
58149ce34c Convert radios on SMS prefix page
Includes changing form.enabled to use
OnOffField, for consistency with other on/off
fields.

OnOffField's data is a boolean, not a string, so
some of the logic using it needed to be changed.
2020-12-09 15:03:43 +00:00
Tom Byers
2e98681a5e Convert radios on set international {sms|letters}
Uses ServiceOnOffSettingForm.enabled.
2020-12-09 15:03:43 +00:00
Tom Byers
ca3d111f03 Merge pull request #3727 from alphagov/add-govuk-radios-2
Add GOVUK radios [part 2]
2020-12-09 14:50:06 +00:00
Leo Hemsted
c805e7bd9c show allowed broadcast provider
in the "training"/"live" window
2020-12-04 10:52:09 +00:00
Chris Hill-Scott
bb34081599 Tell browser to connect to asset domain earlier
When a browser loads a Notify page it does the following:
- DNS and TLS handshake for notifications.service.gov.uk
- download some HTML
- sees that the HTML needs to load some CSS
- DNS and TLS handshake for static.notifications.service.gov.uk
- downloads the CSS

We can speed things up a bit in modern browsers by parallelizing this
process a bit. Modern browsers support some HTTP headers[1] that allow
them to connect to other origins sooner.

After this change the steps are:
- DNS and TLS handshake for notifications.service.gov.uk
- receive response headers and simultaneously:
  - download some HTML
  - DNS and TLS handshake for static.notifications.service.gov.uk
- sees that the HTML needs to load some CSS
- downloads the CSS

1. https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch
2020-12-03 11:01:05 +00:00
Tom Byers
1fea95fae4 Convert radios on link-service-to-org page (basic) 2020-12-02 16:00:33 +00:00
Tom Byers
b1d65f33c7 Convert radios on clear cache page (basic) 2020-12-02 16:00:32 +00:00
Tom Byers
45526598c6 Convert radios on edit org agreement page (basic) 2020-12-02 16:00:32 +00:00
Tom Byers
6aaa4d906b Convert radios on add nhs local org page (basic) 2020-12-02 16:00:32 +00:00
Chris Hill-Scott
b579f68411 Limit jobs sent from contact list by data retention
On the uploads page we only show jobs which are within a service’s data
retention.

This commit does the same for when we’re listing the jobs for a contact
list. This matches the UI, which says a contact list has been ‘used
`<count_of_jobs>` in the last <data_retention> days’
2020-12-01 13:57:56 +00:00
Chris Hill-Scott
c898b68fa8 Add comment explaining mocking
> I'd find it useful to know mock_get_jobs mocks
> app.job_api_client.get_jobs here, perhaps through a comment. Reading
> it, I associated it with contact_list.get_jobs above.
2020-11-30 14:24:40 +00:00
Chris Hill-Scott
a9783f7907 Test for old but unused contact lists
Old contact lists can be:
- never used
- used, but so long ago we no longer have data about the jobs due to
  retention settings

We show different messages in each of these cases. This commit
parametrizes the tests to ensure that both cases are covered.

Also makes the job a bit older so that both cases are logically possible
with the test data.
2020-11-30 14:20:53 +00:00
Chris Hill-Scott
94c713e1b4 Make dates line up in
Having a contact list uploaded in 2020 but used in 2015 isn’t possible,
and so makes the tests confusing to read.
2020-11-30 14:14:26 +00:00
Chris Hill-Scott
45b60e9555 Show usage count on uploads page
Because we’re be grouping jobs under their parent contact lists it’s
good to have some information ‘scent’ to help people find their jobs,
ie by clicking into a contact list. It also lets you see which list have
been used more than others, maybe because the update hasn’t been sent
to that group of people yet.

The hint text under uploads always says when they were used. For contact
lists this is a bit more complicated, since they can:
- never have been used
- been used multiple times

This commit makes use of the new fields being returned by the API to say
determine when these messages are relevant. They also let us
differentiate between a contact list that’s never been used, and one
that has been used, but not recently enough to show any jobs against it.
2020-11-30 13:54:54 +00:00
Chris Hill-Scott
423875011c Show jobs on contact list
It’s a bit unintuitive that starting a job from a contact list makes a
copy of the file, which has no relationship to the list it was copied
from. This is more of an implementation detail, rather than something
that comes from people’s mental models of what is going on. Or at least
that’s what I hypothesise.

I think it’s clearer to show jobs that come from contact lists within
the lists that they were created from. By naming the jobs by template
this gives a clearer view of what messages have been sent to the group
over time.
2020-11-30 13:54:54 +00:00
Chris Hill-Scott
8f5c07336d Add method to get jobs for a contact list
Because the API lets us query jobs by contact list now, let’s add the
model and client layer code that will let us display them in the admin
app.
2020-11-30 13:54:53 +00:00
Chris Hill-Scott
236ddf053d Make created_at a property of contact lists
The view layer shouldn’t be having to deal with converting dates as
strings. This is an artefact of how we send data from the API to the
admin app. The model layer should be responsible for turning JSON into
richer types, where it can.
2020-11-30 13:54:53 +00:00
Katie Smith
1d1973050d Stop live services requesting to go live
Live services shouldn't be able to request to go live again. Once a
service is live we remove the option to go live from the Settings page,
but we still link to the page to request to go live from other places
e.g. the 'Get started' page. As a result, we've seen some services make
another request to go live when their service has already been live for
months - this change will stop that from happening.
2020-11-09 14:00:52 +00:00
Katie Smith
247e7c2d93 Stop checking query string for filename when sending a job
We look for `original_file_name` in the metadata now. Initially we were
still checking the query string too, but now that the change to add the
filename to the metadata has been deployed for a while there shouldn't
be any cases of the filename still being in a query string.

Since the `original_file_name` is not being added to the metadata in
`.check_messages` (it has happened earlier in the process) a few tests
are no longer needed.
2020-11-05 10:03:21 +00:00
Katie Smith
18e4e86565 Stop checking query string for filename if uploading contact list
The code was looking for `original_file_name` in the metadata for a
contact list, or the query string if it wasn't in the metadata. Now that
the change to use the metadata for the file name has been deployed for a
while e can stop looking in the query string for the
`original_file_name`.
2020-11-05 10:03:21 +00:00
Tom Byers
36708ccad0 Merge pull request #3700 from alphagov/fix-template-list-item-focus-style
Fix template list item focus style
2020-10-30 15:58:35 +00:00
Katie Smith
6940291c96 Put filename in metadata when sending via a CSV
When sending from an uploaded CSV `.send_messages` now puts the filename
in the metadata. It previously used the query string to pass the
filename to `.check_messages`, where it can be lost.
2020-10-29 13:53:50 +00:00
Katie Smith
a6c103841e Check metadata for file name when sending from contact list
The `.send_from_contact_list` function redirected to `.check_messages`
with `original_file_name` in the query string. Contact lists already
have `original_file_name` as part of their metadata, so we can stop
sending it in the query string and use the metadata instead.
2020-10-29 13:53:50 +00:00
Katie Smith
e07651ed80 Use metadata to store filename when uploading contact list
We were passing `original_file_name` from the `.upload_contact_list`
view function to the `.check_contact_list` view function as a query
param. We now store it in the metadata instead. `.check_contact_list`
still checks for `original_file_name` in the query string if it's not in
the metadata - this is necessary until the code has been deployed for a
few days and we can be sure that there are no contact lists that are
mid-way through the upload stage.
2020-10-29 13:53:50 +00:00
Chris Hill-Scott
b6e100448d Merge pull request #3687 from alphagov/remove-custom-getattr
Remove custom `getattr` implementation from JSONModel
2020-10-28 10:46:13 +00:00