Commit Graph

3821 Commits

Author SHA1 Message Date
Pea Tyczynska
9ac65ee95c Start sending letters from insolvency service again 2020-10-21 16:56:18 +01:00
Pea Tyczynska
d745ba310e Divide letters by service when putting in ZIPs
When letters are sent to DVLA, we will now put them in a separate
ZIP file for each service, so that if there are printing issues
due to bad files from one service, other services will hopefully
not be affected by that.
2020-10-21 15:19:06 +01:00
Toby Lorne
62951fa039 clients: cbc_proxy tests for handling lambda response
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-10-20 15:26:27 +01:00
Toby Lorne
75de4abd47 clients: cbc_proxy handles lambda invoke response
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
2020-10-20 15:18:11 +01:00
Toby Lorne
73507b3abc clients: cbc_proxy invokes hardcoded function
right now we are doing an end-to-end journey with a CBC from Notify (the
CBE) and we would like to approve a broadcast in notify and have it
appear on our test handset

in order to do this, we:
* hook up the lambda that we made in the correct VPC to cbc_proxy client
* test that it is called correctly

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
Co-authored-by: Pea <pea.tyczynska@digital.cabinet-office.gov.uk>
Co-authored-by: Katie <katie.smith@digital.cabinet-office.gov.uk>
2020-10-20 14:00:53 +01:00
Toby Lorne
ee79768d43 clients: cbc_proxy client uses _ld not _lambda
_ld is better than _lambda because it causes primitive python syntax
highlighting to not get confused

_lambda is better than _ld because it is less jargon

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
Co-authored-by: Pea <pea.tyczynska@digital.cabinet-office.gov.uk>
Co-authored-by: Katie <katie.smith@digital.cabinet-office.gov.uk>
2020-10-20 13:59:52 +01:00
Toby Lorne
14f8e7a5ff clients: cbc_proxy client inits lambda client
Using correct:
* key id
* secret key
* region

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
Co-authored-by: Pea <pea.tyczynska@digital.cabinet-office.gov.uk>
Co-authored-by: Katie <katie.smith@digital.cabinet-office.gov.uk>
2020-10-20 13:33:51 +01:00
Toby Lorne
2cc0a65851 celery: broadcast msg create invokes cbc proxy
When we create a broadcast message, we should invoke the cbc proxy to
send a cap message

Either a function will be invoked within AWS, or a noop function call
is made, depending on the environment

We have only implemented CB message creation in the CBC Proxy, without
polygons, therefore we:
* only invoke the CBC Proxy during message creation
* only send description, identifier, and hard-coded headline

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
Co-authored-by: Pea <pea.tyczynska@digital.cabinet-office.gov.uk>
Co-authored-by: Katie <katie.smith@digital.cabinet-office.gov.uk>
2020-10-20 11:57:26 +01:00
Chris Hill-Scott
182bfa7e10 Remove the upload letters permission
As of https://github.com/alphagov/notifications-admin/pull/3690 it’s no
longer referred to.
2020-10-20 11:46:11 +01:00
Pea Tyczynska
30bd311eb1 Temporarily do not send letters from Insolvency Service
to DVLA. This is a temporary measure over the weekend so that
DVLA can catch up with all other letters.

We should revert this on Monday 19.10.2020
2020-10-16 16:13:32 +01:00
Chris Hill-Scott
8b123fd6a4 Merge pull request #2996 from alphagov/serialise-broadcast-template-content
Serialise content for broadcast templates
2020-10-15 16:35:10 +01:00
Rebecca Law
b2ff4277c9 Adding service_id to the sort order for the letters being sent to print.
We have had a few instances where letters have caused problems. Particularly for precompiled letters, often the issue comes from the same service.
The hope is that by adding a sort order this will help the print provider narrow down the problem.

There is a small degradation of the performance of the query, but it's not enough to concern me.
2020-10-15 09:39:07 +01:00
Chris Hill-Scott
3a2081dc06 Serialise content for broadcast templates
Broadcast services only have broadcast templates. But on the frontend
we show the template type under the name of the template. This is
redundant. It would be better to preview the content of the template
instead.

At the moment we can’t do this because we optimised the template schema
response to not include the content of the templates in
https://github.com/alphagov/notifications-api/pull/2880

This commit reverses that optimisation, for broadcast templates only,
and expands the tests to cover all template types.
2020-10-13 16:27:29 +01:00
Pea M. Tyczynska
50982ff36a Merge pull request #2991 from alphagov/reset-password-email-gets-forward-link
Put redirect link in reset password email link
2020-10-12 12:26:42 +01:00
Chris Hill-Scott
57473ef65d Rename template_content to content
`template_content` is a template that hasn't had its placeholders filled
in whereas content is where it would have (which is what has happened
above)
2020-10-08 11:39:17 +01:00
Chris Hill-Scott
80352bafe1 Update test to check personalisation
While the API still has a column and field for personalisation I think
it makes sense for it to consider the personalisation when serialising
the broadcast, so we should have a test for this.

This way the API still works as a coherent whole, and the admin app just
happens to be a client of the API which doesn’t implement the
personalisation feature.

If we want to remove personalisation from the API at another time we
should do it wholesale.
2020-10-07 10:52:31 +01:00
Pea Tyczynska
e91deff448 Put redirect link in reset password email link
This is so when users reset their password they are still
redirected to pages they were meant to visit.

This change was done specifically so everyone who is meant to see
broadcast tour sees it, but it will improve lives of all users
who wanted to visit a page on Notify but then had to reset
their password in the process
2020-10-05 16:58:10 +01:00
Chris Hill-Scott
7da0d46767 Serialise content in broadcast message response
This will let us show the content of the broadcast message in places we
can’t at the moment.
2020-10-02 16:39:24 +01:00
David McDonald
cfe32cf459 Merge pull request #2975 from alphagov/rename-redis-template-keys
Step 2 of renaming cache keys for templates
2020-10-02 14:26:03 +01:00
Chris Hill-Scott
f2314333b5 Merge pull request #2982 from alphagov/improve-efficiency-of-process-missing-rows
Improve efficiency of process missing rows task
2020-10-02 11:23:35 +01:00
Chris Hill-Scott
19963b9b58 Merge pull request #2984 from alphagov/add-stats-endpoint-for-scheduled-jobs
Add an endpoint for stats about scheduled jobs
2020-09-29 10:24:09 +01:00
Leo Hemsted
59839d21b8 Merge pull request #2974 from alphagov/make-letter-folder-name-code-readable
Make letter folder name code readable
2020-09-28 13:58:08 +01:00
Chris Hill-Scott
4cee47da68 Add more tests for scheduled job stats
Ensures we don’t count jobs that are in a different status, or belong to
another service.
2020-09-28 13:15:39 +01:00
Rebecca Law
e4e61b1e4b Merge pull request #2978 from alphagov/add-reference-to-msg
Add reference to log message
2020-09-28 12:04:59 +01:00
Chris Hill-Scott
2fcde009ac Add an endpoint for stats about scheduled jobs
At the moment we display the count of scheduled jobs on the dashboard
by sending all the scheduled jobs to the admin app and letting it work
out the stats.

This is inefficient and, because the get jobs response has a page size
of 50, becomes incorrect if a service schedules more than 50 jobs.

This commit adds a separate endpoint which gives the admin app the stats
it needs directly and correctly.
2020-09-28 09:57:32 +01:00
Chris Hill-Scott
1d50bfaafc Remove unused column from query 2020-09-26 12:11:15 +01:00
Chris Hill-Scott
aace1bdd8a Allow 20 minutes before checking for missing rows
Since we’ve doubled the number of rows in a job, jobs can take twice as
long to insert all the notifications. We don’t check for missing rows
until we’re pretty confident that the original tasks have finished
processing. This means we need to double the time we wait to still be
as sure.
2020-09-26 11:38:38 +01:00
Rebecca Law
d7e53cdf50 Adding reference to message for "precompiled letters have been pending-virus-check for over 90 minutes"
This saves having to go to the db to get it.
2020-09-24 14:16:16 +01:00
David McDonald
5b0cc8819a Use new redis key for templates
Equivalent of https://github.com/alphagov/notifications-admin/pull/3639
but for the API.

This is the only place in the API we appear to be getting setting
templates or broadcast messages.
2020-09-21 17:40:54 +01:00
Leo Hemsted
1e928a926a rename sending_date to created_at
we don't name letters based on the day we send them on, rather, the day
we create them on. If we process a letter for a second time for whatever
reason, even if it's a couple of days later, it'll still go in a folder
based on the created_at timestamp. There's still a slight confusion,
however - if the timestamp is after 5:30pm, the folder will be for the
day after. However, still the day after creation, so I think created_at
still makes the most sense.

Remove the term `sending_date` to try and make this relationship more
apparent.
2020-09-21 14:40:22 +01:00
Leo Hemsted
4f1e5ee5a3 remove ignore_folder from get_folder_name
it doesn't make sense to get the folder name if you know you aren't
going to use it.
2020-09-21 14:33:38 +01:00
Leo Hemsted
bb33927b3d rename letter get_folder_name args
`_now`? why would we ever use a different _now? instead say created_at,
because that's what it'll always be set to, even if we're replaying old
letters. We always set the folder name to when the letter was
created_at, or we might not know where to look to find it.

`dont_use_sending_date` doesn't really tell us what might happen if we
don't use it - the answer is we return an empty string. we ignore the
folder entirely. so lets call it that.

Also, remove use of freeze_gun in the tests, to prove that we don't use
the current time in any calculations. Also add an assert to a mock in
the get_pdf_for_templated_letter test, because we were mocking but not
asserting before, so the tests didn't fail when the function signature
changed.
2020-09-21 14:32:57 +01:00
David McDonald
120b760cae Merge pull request #2972 from alphagov/broadcast-invite-template
Broadcast invite template
2020-09-16 14:34:31 +01:00
David McDonald
f9911c7965 Send broadcast invite email for broadcast service invites
This means the copy is more accurate and mentions sending emergency
alerts rather than previous copy about sending emails texts and letters.
2020-09-15 16:47:41 +01:00
David McDonald
23ac7bcf56 Use sample broadcast service instead of sample service for tests
We only want to use a service that has permissions for broadcasts to
make our tests more realistic
2020-09-15 16:47:41 +01:00
Katie Smith
aee7887c14 Fix the filenames for international precompiled letters
We were determing the filename for precompiled letters before we had
checked if the letters were international. This meant that a letter
could have a filename indicating it was 2nd class, but once we had
sanitised the letter and checked the address we were setting the
notification to international.

This stopped these letters from being picked up to be sent to the DVLA,
since the filename and postage of the letter did not match.

We now regenerate the filename after the letter has been sanitised (and when
we know the postage) and use the updated filename when moving the letter
into the live PDF letters bucket.
2020-09-15 16:17:33 +01:00
David McDonald
5b2dee5ddb Bump utils to 42.0.0
Requires unit test updating as we now expect broadcast event areas to
be a dict containing a list of areas and simple polygons.
2020-09-14 15:21:55 +01:00
David McDonald
d352c99142 Remove unused send_broadcast_message task
We only call send_broadcast_event now
2020-09-14 15:16:59 +01:00
David McDonald
5aee6269e0 Fix format of simple_polygons
It is not of the form
[[lat, long][lat, long]] as this would only hold a single polygon. It
instead needs to handle multiple polygons so instead is of the form
[[[lat, long][lat, long]]].
2020-09-14 14:55:01 +01:00
Chris Hill-Scott
92af5b8d67 Merge pull request #2968 from alphagov/cancel-international-letters
Allow international letters to be cancelled
2020-09-09 14:10:23 +01:00
Chris Hill-Scott
cfda289746 Allow international letters to be cancelled
Our code was assuming that any notifications with `international` set to
`True` were text messages. It was then trying to look up delivery
information for a notification which wasn’t sent to a phone number,
causing an exception.
2020-09-09 10:55:55 +01:00
Rebecca Law
795a035fac When the organisation updates the crown attribute it should update all the services associated with that organisation too. 2020-09-09 10:43:16 +01:00
Pea Tyczynska
b3ff172780 Validate that both polygons and areas have to be updated
Because areas and polygons for broadcast messages should
be in sync.
2020-09-07 15:54:31 +01:00
Pea Tyczynska
5927aae019 Serialise simple_polygons attribute of BroadcastMessage 2020-09-07 15:54:31 +01:00
Pea Tyczynska
2f6b96dafc Ensure broadcast with no areas cannot be approved
This is already checked by admin app, but we want to have a
fallback safety measure as a precaution.
2020-09-07 15:54:30 +01:00
Pea Tyczynska
5cf6e1cf72 Persist simple polygons in the db.
They are being sent over from admin, and persisted
in the db so we can send them on to the broadcast
provider later on.
2020-09-07 15:52:14 +01:00
Rebecca Law
93475912ba Merge pull request #2950 from alphagov/international-letters-for-all
Default international_letters for service permissions.
2020-09-07 07:39:52 +01:00
Katie Smith
b30701d7e1 Set 'international' for letters in ft_billing
`international` for letters in `ft_billing` was always False. Now that
letters can be international, this changes the column value to the value
of `international` for the notification.
2020-08-21 09:19:27 +01:00
Katie Smith
8dcc65d11c Add endpoints to get invited users
We want to display flash messages in admin when invites have been
cancelled. This message needs to display the user's email address, so
this commit adds endpoints to GET a single invited service user and org
user so that we can look up the email address of a cancelled user.
2020-08-19 08:49:33 +01:00
David McDonald
db0655472a Merge pull request #2957 from alphagov/missing-template-version
Fix bug with missing template version param
2020-08-17 17:33:29 +01:00