Commit Graph

9728 Commits

Author SHA1 Message Date
Chris Hill-Scott
f5649d72c9 Explain 3 required address columns
Our rules about address columns are relaxing, so that none of them are
mandatory any more. Instead you just need any 3 of the 7 to make a valid
address.

This commit updates our error messaging to reflect that.
2020-04-27 16:47:49 +01:00
Rebecca Law
b2118057ef Merge pull request #3426 from alphagov/update-utils-large-frag-count
Update utils to the latest version
2020-04-27 16:41:58 +01:00
Rebecca Law
347209f5c0 Fix typo 2020-04-27 13:52:37 +01:00
Rebecca Law
8c7495ea45 Update the pricing page 2020-04-27 13:51:29 +01:00
Rebecca Law
48a49f24f0 Update utils to the latest version
The validation for the text message character count has been updated from 612 to 918.

The pricing page still needs to be updated.
2020-04-27 10:27:43 +01:00
Pea M. Tyczynska
33786fc3d9 Merge pull request #3423 from alphagov/update-healthcheck-page
Update _status page - remove references to Travis
2020-04-24 14:37:41 +01:00
Chris Hill-Scott
f79527bfd9 Merge pull request #3413 from alphagov/delay-initial-ajax-call
Delay the initial AJAX call by 2 seconds
2020-04-24 12:06:19 +01:00
Pea Tyczynska
652b627312 Update healthcheck page and remove all travis references from the repository 2020-04-24 11:54:26 +01:00
Chris Hill-Scott
bc4f2166cd Merge pull request #3422 from alphagov/fix-sms-preview-activity
Fix preview of text messages on activity page
2020-04-23 11:30:28 +01:00
Chris Hill-Scott
79b32a11ce Add comments to explain where fixture data comes from
https://github.com/alphagov/notifications-admin/pull/3422#discussion_r413120404
2020-04-23 10:12:02 +01:00
Katie Smith
77f90da5c5 Merge pull request #3421 from alphagov/archive-user-error-msg
Show error when user cannot be archived
2020-04-23 08:57:04 +01:00
Chris Hill-Scott
8faffad508 Pin WTForms to current version
Version 2.3.0 contains a number of breaking changes which we can address
later.
2020-04-22 16:40:56 +01:00
Katie Smith
407c6d264c Fix assertion in test
When using `with pytest.raises...` any assertions inside the `with`
statement that occur below the line that raises the exception don't get
called. It's not possible to check the response status_code / location
in this test because an exception is raised before the response is
returned.
2020-04-22 16:31:59 +01:00
Chris Hill-Scott
0d92664fc8 Fix preview of text messages on activity page
Also beefs up the tests a bit so we can be more confident that the right
thing is getting displayed.

Depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/725
2020-04-22 16:10:40 +01:00
Katie Smith
ffdcda02bf Show error when user cannot be archived
A user can't be archived if they are the only member of their service
with `manage_settings` permission. `notifications-api` returns a `400`
and an error message if that is the case, however this PR to remove the
`400` error handler
https://github.com/alphagov/notifications-admin/pull/3320 stopped the
error message from showing. This meant that instead of seeing a message
about why a user couldn't be archived, we would just show a `500` error
page instead. This change checks the response from `notifications-api`
and shows an error banner with a message if the user can't be archived.
2020-04-21 18:35:36 +01:00
David McDonald
f91aba212d Merge pull request #3419 from alphagov/sms-sender-length
Reduce min sender length from 4 to 3
2020-04-21 14:53:52 +01:00
David McDonald
9f557dd086 Reduce min sender length from 4 to 3
This is now supported at the network and aggregator level
2020-04-21 12:51:54 +01:00
Chris Hill-Scott
52e966337d Merge pull request #3418 from alphagov/fix-letter-branding-preview
Fix letter branding preview
2020-04-21 11:35:45 +01:00
Chris Hill-Scott
e56c2d28b0 Fix letter branding preview
Template preview requires `template_type` to be passed in now.
2020-04-21 11:21:02 +01:00
Chris Hill-Scott
788edc46f2 Merge pull request #3415 from alphagov/normalise-2fa-code-input
Allow spaces and dashes in the two factor code
2020-04-21 10:14:19 +01:00
Chris Hill-Scott
0f686a7b3a Merge pull request #3411 from alphagov/whole-row-errors
Show errors that aren’t specific to a single spreadsheet column across the whole table row
2020-04-20 12:59:11 +01:00
Chris Hill-Scott
c36e75b3db Add test for message too long error
This didn’t seem to be tested anywhere before. We want to make sure it
works in the same sort of way as the message is empty error, which is
tested.
2020-04-20 12:35:59 +01:00
Chris Hill-Scott
b0cf36e1c7 Allow spaces and dashes in the two factor code
I noticed when using the dication software that saying ‘one two three
four five’ got dictated as `123 45`. This tripped the validation,
because the space character isn’t a digit.

So this commit normalises out spaces (and other spacing characters like
dashes and underscores) before validating the code and sending it to the
API.

I can also imagine that some people might like to space out the code to
make it easier to transcribe (like you might do with a credit card
number).
2020-04-17 16:16:52 +01:00
Chris Hill-Scott
e2d1401b54 Show error across the whole row
Errors with messages being too long or empty aren’t specific to a single
cell of the uploaded spreadsheet, they’re the results of combining all
the cells with the template.

Previously we could only show errors against a specific cell. This
commit makes it possible to add a super-row which spans all the cells,
into which we can put errors.

The index (header) column then spans both these rows, to show that they
are both associated with the same row of input.

Depends on:
- [x] https://github.com/alphagov/notifications-utils/pull/719
2020-04-17 11:06:34 +01:00
Chris Hill-Scott
f37137cdb3 Convert list table to mapping table
A list table takes a list of input, and assumes one row of output. In
order to show errors that span multiple rows we need to output two rows
for one item of input.

The list table inherits from the mapping table; using the mapping table
directly gives us the flexibility we need.
2020-04-17 11:06:33 +01:00
Chris Hill-Scott
8ce1497fc0 Make test more specific
Tests that just assert some content `in` the whole page are tricky to
debug, and make it harder to be sure that said content is showing up in
the right place, with the right markup and styling.
2020-04-17 11:06:33 +01:00
Chris Hill-Scott
202d4cdb5a Merge pull request #3414 from alphagov/moj-bank-holidays
Remove hard-coded bank holidays
2020-04-17 11:04:27 +01:00
Chris Hill-Scott
aeb1d29f7f Merge pull request #3412 from alphagov/bump-utils-template-classes
Bump utils to bring in recent changes to Template classes
2020-04-17 11:04:19 +01:00
Chris Hill-Scott
e68f9c6db9 Remove hard-coded bank holidays
Looks like someone in the Ministry of Justice has made a nice little
Python package of them.

I’ve configured it to use the cached holidays that come with the
package, rather than going to the GOV.UK website every time we start the
app. This should be more reliable, and means we’ll only get updates when
we do a version bump (PyUp should keep an eye on this for us).
2020-04-16 15:06:54 +01:00
Chris Hill-Scott
8da16468ff Delay the initial AJAX call by 2 seconds
At the moment the first AJAX call is triggered as soon as the page
loads. We then look at its response time to work out how long to wait
until making the next call.

This isn’t great because:
- stuff is unlikely to have changed straight away, so it’s a waste of a
  call
- while the DOM is being updated it seems to introduce a delay in
  clicks on links, which is either more pronounced or more noticeable
  when it’s happening straight away, making the UI feel less snappy

I chose a value of 2 seconds as a rough proxy for the minimum time we’d
expect to see a notification go from created to delivered. Median
time-to-delivered was 2.9 seconds when we analysed it for
https://github.com/alphagov/notifications-admin/pull/2974#discussion_r286101286
2020-04-16 13:21:24 +01:00
Chris Hill-Scott
88734bb74f Bump utils to bring in recent changes to Template classes
The main things we have to account for are:
- `WithSubjectTemplate` has gone
- every template dictionary must have `template_type` set
2020-04-15 17:58:57 +01:00
Chris Hill-Scott
1cebd74403 Merge pull request #3407 from alphagov/fix-address-one-off
Fix one off letter journey if you have a placeholder from the address block
2020-04-15 16:14:08 +01:00
Chris Hill-Scott
157ab82fea Fix back link on check notifications page
It wasn’t using the same logic around placeholders and address lines as
the rest of the send one off steps.
2020-04-15 15:42:25 +01:00
Chris Hill-Scott
f773a6ed71 Factor out skip link to reduce complexity
The code was too complex and Flake8 was complaining.

While this code isn’t related to the change we’re making it is easy
enough to factor out.
2020-04-14 15:20:03 +01:00
Chris Hill-Scott
d31c244363 Don’t send users back to a page that will send them forward again
If you’re on a page with a normal placeholder and the previous
placeholder is one that’s also in the address block then going back to
the previous page will send you immediately forward to the current page
again.

This commit makes the back link a bit smarter by skipping over pages
where it can see that they relate to a placeholder from the address
block.

If it gets all the way to the start of the list of placeholders without
finding any non-address ones then it will default to generating a link
that will redirect the user to filling in the address block again.
2020-04-14 15:20:03 +01:00
Chris Hill-Scott
b68dd569fc Skip over placeholders if they’re in the address
We don’t really want you modifying lines of the address after you’ve
entered it. Especially when it might not be obvious that modifying the
address line placeholder will modify the address you’re sending the
letter to.
2020-04-14 15:19:29 +01:00
Chris Hill-Scott
6c7e6fa64e Remove the code to handle optional address placeholders
Optional address placeholders aren’t a thing for one-off letters any
more, so we can tidy up the code a bit by removing the parts of the flow
that are accounting for them.
2020-04-14 15:19:29 +01:00
Chris Hill-Scott
53918f8d9f Don’t go back to address if address placeholder in letter
If you have an placeholder from the address block elsewhere in your
letter then you currently get redirected to the address block page
instead of being offered to fill that placeholder in. This commit
tightens up the check to only do this when the placeholder is in the
first 7 placeholders, which is where we store the address placeholders.
2020-04-14 15:19:29 +01:00
Leo Hemsted
713980a35e Merge pull request #3410 from alphagov/letter-timing-fix
fix letter notification status around UTC/BST
2020-04-14 14:23:38 +01:00
Chris Hill-Scott
66b748bfd2 Merge pull request #3409 from alphagov/introspect-dynamic-model-properties
Make dynamic attributes of model introspectable
2020-04-14 14:19:09 +01:00
Leo Hemsted
671d0872c2 fix letter notification status around UTC/BST
timezones grr blah blah blah
2020-04-14 09:52:13 +01:00
Chris Hill-Scott
23e1682260 Make dynamic attributes of model introspectable
`dir(object)` is a useful Python function that tells you what attributes
and methods an object has. It’s also used by tools like iPython and IDEs
for code completion.

Some of the attributes of a `JSONModel` are dynamic, based on what
fields we expect in the underlying JSON. Therefore they don’t
automatically end up in the result of calling `dir`. To get around this
we can implement our own `__dir__` method, which also returns the names
of the fields we’re expecting the the JSON.

Inspired by this Raymond Hettinger tweet:

> #python tip:  If you add attributes to an API with __getattr__() or
> __getattribute__(), remember to update __dir__() to make the extension
> introspectable.

— https://twitter.com/raymondh/status/1249860863525146624
2020-04-14 09:44:38 +01:00
Chris Hill-Scott
cee7277b47 Merge pull request #3405 from alphagov/ajax-backoff
Delay AJAX calls if the server is slow to respond
2020-04-09 12:19:32 +01:00
Chris Hill-Scott
a2929ad748 Delay AJAX calls if the server is slow to respond
By default our AJAX calls were 2 seconds. Then they were 5 seconds
because someone reckoned 2 seconds was putting too much load on the
system. Then we made them 10 seconds while we were having an incident.
Then we made them 20 seconds for the heaviest pages, but back to 5
seconds or 2 seconds for the rest of the pages.

This is not a good situation because:
- it slows all services down equally, no  matter how much traffic they
  have, or which features they have  switched on
- it slows everything down by the same amount, no matter how much load
  the platform is under
- the values are set based on our worst performance, until we manually
  remember to switch them back
- we spend time during incidents deploying changes to slow down the
  dashboard refresh time because it’s a nothing-to-lose change that
  might relieve some symptoms, when we could be spending time digging
  into the underlying cause

This pull request makes the Javascript smarter about how long it waits
until it makes another AJAX call. It bases the delay on how long the
server takes to respond (as a proxy for how much load the server is
under).

It’s based on the square root of the response time, so is more sensitive
to slow downs early on, and less sensitive to slow downs later on. This
helps us give a more pronounced difference in delay between an AJAX call
that is fast (for example the page for a single notification) and one
that is slow (for example a dashboard for a service with lots of
traffic).

*Some examples of what this would mean for various pages*

Page | Response time | Wait until next AJAX call
---|---|---
Check a reply to address | 130ms | 1,850ms
Brand new service dashboard | 229ms | 2,783ms
HM Passport Office dashboard | 634ms | 5,294ms
NHS Coronavirus Service dashboard | 779ms | 5,977ms
_Example of the kind of slowness we’ve seen during an incident_ | 6,000ms | 18,364ms
GOV.UK email dashboard | `HTTP 504` | 😬
2020-04-09 12:05:18 +01:00
Katie Smith
83fe0b0be3 Merge pull request #3406 from alphagov/letter-too-long-content
Update letter too long content
2020-04-09 11:29:49 +01:00
Katie Smith
2c7e7fbc4b Merge pull request #3403 from alphagov/pdf-bug-fix
Specify mimetype for PDF letters to be downloaded
2020-04-09 11:29:39 +01:00
Katie Smith
0b81b697c2 Delete commented code
This content was all moved to other pages.
2020-04-09 11:04:20 +01:00
Katie Smith
13650b7d4b Update error messages for letters that are too long
To specify the number of sheets as well as pages in case this is not
clear.
2020-04-09 11:03:07 +01:00
Katie Smith
6b055071f4 Specify mimetype for PDF letters to be downloaded
We had a report that when clicking on the 'Download this letter' link on
the notification page the file was not being downloaded as a PDF file
but was given a `.htm` file extension instead. We should be able to stop
that happening by using Flask's `send_file` function with the right mimetype.
This change updates the `view_letter_notification_as_preview` to use
`send_file` and splits out code to get the file data into a separate
function.

Mocks in the tests have been updated and some unused mocks removed.
2020-04-09 10:35:30 +01:00
Tom Byers
2992aacd8a Merge pull request #3404 from alphagov/fix-time-in-cookies-tests
Fix timestamp used for clearing old cookies
2020-04-08 09:17:48 +01:00