Commit Graph

9680 Commits

Author SHA1 Message Date
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
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
Tom Byers
6d620dd283 Fix timestamp used for clearing old cookies
The code in the test that added the 'old' cookies
uses Greenwich Mean Time (GMT) format:

https://github.com/alphagov/notifications-admin/blob/master/tests/javascripts/support/helpers/cookies.js#L19

The code that cleared any 'old' cookies doesn't
specify a time format so uses that set on the host
OS:

https://github.com/alphagov/notifications-admin/blob/master/app/assets/javascripts/cookieMessage.js#L12
https://github.com/alphagov/notifications-admin/blob/master/app/assets/javascripts/cookieMessage.js#L19

Cookies are deleted by setting the data to one
that has expired. Because of the hour difference
the date set to make the cookies expire didn't
work.

This fixes that by making the clearing up code use
GMT.
2020-04-08 08:51:53 +01:00
Chris Hill-Scott
8219b5aa79 Merge pull request #3402 from alphagov/fix-send-one-off-letter-post
Fix API call to send one off letter
2020-04-07 13:28:35 +01:00
Chris Hill-Scott
f06ff5f65f Fix API call to send one off letter
As part of making the API call we extra the recipient from the first
line of the address. This code was assuming that the recipient would
always have the key `address line 1`, but we’re no longer guaranteeing
that it will be capitalised and spaced exactly like that.
2020-04-07 12:59:34 +01:00
Chris Hill-Scott
d70172a452 Merge pull request #3400 from alphagov/validate-postcode-templated-one-off
Add postcode validation check for one-off letters
2020-04-07 12:15:55 +01:00
Chris Hill-Scott
54d7c6fcbd Get ready to error for precompiled letters with bad addresses
Template preview is going to start returning these errors; we need to be
ready to handle them.
2020-04-07 09:09:03 +01:00
Chris Hill-Scott
c646c16067 Add postcode validation check for one-off letters
We’re doing this everywhere else now, so this completes the story.

It uses the same regex as elsewhere and the error messaging is
consistent (but not uniform) with the other places.
2020-04-07 09:08:51 +01:00
Chris Hill-Scott
26f702ebce Refactor to use PostalAddress helper from utils
Since we’re doing normalisation and line-count-checking of addresses in
multiple places it makes sense for that code to be shared. Which is
what happened here:
https://github.com/alphagov/notifications-utils/pull/713

This commit refactors the admin code to make use of the new utils code.

Note about placeholders:
- they now go into the session as `address_line_1` instead of `address
  line 1` because this is the format the API uses, so should be
  considered canonical
- they are now fetched from the session in a way that isn’t sensitive
  to case or underscores (using the `Columns` class)
- the API doesn’t care about case or underscores vs spaces in
  placeholder names because it’s checking an instance of `Template` to
  see if all the required placeholders are present (see
  401c8e41d6/app/notifications/process_notifications.py (L40))
2020-04-07 09:00:55 +01:00
Pea M. Tyczynska
32eef2f203 Merge pull request #3401 from alphagov/tighten-erorr-check
Tighten error check for duplicate reply to email addresses
2020-04-06 11:30:27 +01:00
Pea Tyczynska
aacd96a6b9 Tighten check for reply to address conflict error
The check was made more permissive temporarily as we were changing
error code we are returning form API from 400 to 409.
2020-04-06 10:51:16 +01:00
Chris Hill-Scott
17f4d3cfff Merge pull request #3399 from alphagov/underscores-in-sms-senders
Allow underscores in SMS senders
2020-04-02 16:03:59 +01:00
Chris Hill-Scott
1fe3f1871e Allow underscores in SMS senders 2020-04-02 15:57:46 +01:00
Chris Hill-Scott
c400695f68 Merge pull request #3398 from alphagov/fix-unecessary-call-to-get-org
Fix unnecessary call to organisation API endpoint
2020-04-02 15:37:41 +01:00
Chris Hill-Scott
047ca8a48c Fix unnecessary call to organisation API endpoint
We’re caching the organisation name, but still talking to the API
to see if the organisation exists.

`Service().organisation_id` only goes to the JSON for the service.

`Service().organisation` makes a separate API call.

We only need the former to know if a service belongs to an organisation.
2020-04-02 15:24:02 +01:00
Pea M. Tyczynska
a709ee4a29 Merge pull request #3397 from alphagov/postcode-validation
Handle postcode validation for precompiled letters
2020-04-02 14:12:39 +01:00
Pea Tyczynska
86ab0a6a0f Add missing test cases for precompiled validation messages 2020-04-02 13:39:40 +01:00
Chris Hill-Scott
00404a0017 Merge pull request #3391 from alphagov/cache-organisation-name
Cache organisation name in Redis
2020-04-02 13:26:31 +01:00
Chris Hill-Scott
0904ac0533 Make fixture for getting service with organisation
Saves repeatedly defining the same mock.
2020-04-02 13:12:06 +01:00
Chris Hill-Scott
51a5a4b559 Remove unused client method
The app is now always getting an organisation by its `id` (or domain),
and never by `service_id`.

This means that the client method and associated mocking can be removed.

I think this must come from a time when the service response didn’t
include `organisation_id`, but now it always does.
2020-04-02 12:07:20 +01:00
Chris Hill-Scott
cc5701e870 Cache organisation name in Redis
A lot of pages in the admin app are now generated entirely from Redis,
without touching the API.

The one remaining API call that a lot of pages make, when the user is
platform admin or a member of an organisation, is to get the name of
the current service’s organisation.

This commit adds some code to start caching that as well, which should
speed up page load times for when we’re clicking around the admin app
(it’s typically 100ms just to get the organisation, and more than that
when the API is under load).

This means changing the service model to get the organisation from the
API by ID, not by service ID. Otherwise it would be very hard to clear
the cache if the name of the organisation ever changed.

We can’t cache the whole organisation because it has a
`count_of_live_services` field which can change at any time, without an
update being made.
2020-04-02 12:07:19 +01:00
Pea Tyczynska
0a7fa1f799 Update content for postcode valdiation handling for precompiled 2020-04-02 11:45:57 +01:00
Pea Tyczynska
5036511803 Handle postcode validation 2020-04-02 11:23:17 +01:00
Chris Hill-Scott
c448eb8995 Merge pull request #3388 from alphagov/remove-contact-list-hint
Remove line about contact lists from uploads
2020-04-02 11:04:14 +01:00
Chris Hill-Scott
1947b62ed9 Merge pull request #3396 from alphagov/fix-relative-date-for-returned-letters
Fix relative date for returned letters
2020-04-02 09:58:31 +01:00
Chris Hill-Scott
e8b5de533d Fix relative date for returned letters
It was saying ‘16 hours ago’ instead of today. This is because, in
strftime:
- `%M` means minute, not month
- `%D` means short MM/DD/YY date, not day of the month

The test wasn’t catching this because the freeze time and mocked value
from the API were set to the same minute.
2020-04-01 17:38:06 +01:00
Chris Hill-Scott
84e063c901 Merge pull request #3371 from alphagov/flask-login-again
Flask login (but backwards compatible)
2020-04-01 16:14:38 +01:00
Chris Hill-Scott
3752b44ce8 Merge pull request #3369 from alphagov/address-block-part-deux
one off letter address form part deux
2020-04-01 16:14:27 +01:00
Chris Hill-Scott
fef822d470 Merge pull request #3395 from alphagov/update-humanize
Update humanize from 1.0.0 to 2.2.0
2020-04-01 16:00:50 +01:00
pyup-bot
1dc9f0aa5d Update humanize from 1.0.0 to 2.2.0 2020-04-01 14:37:12 +01:00
Chris Hill-Scott
3895794208 Merge branch 'master' into flask-login-again 2020-04-01 14:29:16 +01:00
Chris Hill-Scott
f6a286ca4f Merge pull request #3314 from alphagov/itsdangerous-upgrade
Upgrade itsdangerous
2020-04-01 13:50:49 +01:00
Chris Hill-Scott
7930dc0b4a Merge pull request #3345 from alphagov/returned-letters-stats
Use statistics for returned letters on dashboard
2020-04-01 10:44:08 +01:00
Chris Hill-Scott
61d87bf6c0 Let platform admins delete returned letters cache
Just in case there’s ever a problem with something in these caches. We
missed this before.
2020-04-01 10:18:56 +01:00
Chris Hill-Scott
7fb8e1de92 Use statistics for returned letters on dashboard
This should be faster and more accurate than querying all the reports.
2020-04-01 10:18:55 +01:00
Leo Hemsted
3529188968 redirect from address_line_n to address textarea page
if someone starts a new one-off flow they'll get taken to the address
page. However, if someone hits the back button, they'll cycle backwards
through placeholders and will end up on the individual line pages. Lets
redirect them to the correct place.

We'll additionally need to reconstruct the address block from the
various session variables that may or may not be populated
2020-03-31 16:59:48 +01:00
Leo Hemsted
c3fa8ab2e1 Merge pull request #3368 from alphagov/address-block
one off letter address form
2020-03-31 16:08:11 +01:00
Pea M. Tyczynska
2bb47af3c3 Merge pull request #3389 from alphagov/fix-unhandled-errpr
Fix bug where adding same reply-to-email twice for the same service caused a 5xx
2020-03-31 14:08:02 +01:00
Katie Smith
f7f31de2e7 Merge pull request #3394 from alphagov/bump-utils
Bump utils to 36.9.3 to bring in new version of Bleach
2020-03-31 11:08:12 +01:00
Katie Smith
435081a2a4 Bump utils to 36.9.3 to bring in new version of Bleach 2020-03-31 08:59:45 +01:00
Leo Hemsted
c4d839d4f5 input letter address data in a single block
rather than in multiple placeholders - this is the first step towards
making postcodes non-required, which is the first step towards
international letters.

they still populate address_line_# and postcode fields under the hood -
to keep validation working the same, the last line always goes into
`postcode`.

the form normalises whitespace, removes extra new lines, and enforces
that you have between three and seven lines.

if the letter repeats address placeholders further down (eg "Dear
((address_line_1))"), then it'll fill those in as well. It'll still
prompt you to fill them in, but they'll be pre-filled.
2020-03-30 19:29:26 +01:00
Leo Hemsted
df51bf6f5f small QOL changes in conftest
if we are asserting on a redirect we expect the result to be 302 (you
could still override this to 301 if you want).

also give some function calls kwargs to make them easier to read
2020-03-30 18:05:50 +01:00
Pea Tyczynska
ebe2c1c4ae Accept 409 conflict response code when reply-to address already exists
Also stop checking error message.
2020-03-30 17:31:00 +01:00
Chris Hill-Scott
57ec58ab4e Merge pull request #3377 from alphagov/delete-contact-list
Let users delete a contact list
2020-03-27 16:13:32 +00:00
Chris Hill-Scott
3aabe7cce8 Merge pull request #3390 from alphagov/tabular-numbers-template-stats
Use tabular figures for template statistics
2020-03-27 09:56:10 +00:00
Chris Hill-Scott
dd6944e8ef Use tabular figures for template statistics
We use tabular (not lining) figures everywhere else that we display
counts, so that they don’t shift around as the AJAX updates the numbers.

There’s a good explanation of the difference here:
https://www.fonts.com/content/learning/fontology/level-3/numbers/proportional-vs-tabular-figures
2020-03-27 09:30:28 +00:00
Pea Tyczynska
6e78541008 Fix bug where adding same reply-to-email twice for the same service caused a 5xx
This was due to changed quotataion marks in error message.
2020-03-26 17:44:19 +00:00
Chris Hill-Scott
7582b8face Remove line about contact lists from uploads
This line doesn’t make sense now that you can upload a contact list in
advance of having a template.
2020-03-26 17:17:11 +00:00
Chris Hill-Scott
8a093fd34c Merge pull request #3338 from alphagov/remove-permission-checks-uploads
Clean up the codebase after moving everyone to the new uploads page
2020-03-26 17:00:16 +00:00
Chris Hill-Scott
d41d0cfb67 Merge pull request #3387 from alphagov/add-who-can-use-page
Add ‘Who it’s for’ page
2020-03-26 15:15:44 +00:00