Commit Graph

3470 Commits

Author SHA1 Message Date
Katie Smith
3a07d1e13d Create new sms-callbacks queue
The `delivery-worker-receipts` app will listen to this new queue, which will
be used for processing the responses from Firetext and MMG.
2020-03-19 13:41:14 +00:00
Katie Smith
19bf68b567 Delete unused function 2020-03-19 13:41:14 +00:00
Pea M. Tyczynska
900664c172 Merge pull request #2748 from alphagov/format-postcode-for-csvs
Format postcode for CSV letter rows
2020-03-19 11:07:08 +00:00
Rebecca Law
7459a4f6f6 Add a try/except around the code to get the files.
The idea is to log the exception but keep going. That way the "good" files still get sent and we can investigate why a file failed.
2020-03-19 09:15:38 +00:00
Rebecca Law
852cf478f8 Remove the check for daily limits 2020-03-17 15:51:21 +00:00
Rebecca Law
ac07ea3e3f Merge pull request #2755 from alphagov/fix-serialization-error
Fix serialisation error
2020-03-17 10:44:47 +00:00
Chris Hill-Scott
6667c04cf2 Fix unused import 2020-03-17 10:07:47 +00:00
Rebecca Law
51f43563d3 Fix serialisation error when creating the create_letters_pdf in resend_created_notifications_older_than 2020-03-17 08:48:02 +00:00
Rebecca Law
95c2dabaca Add service_contact_list id to the JobSchema. 2020-03-17 08:20:01 +00:00
Pea Tyczynska
1fb040dc61 Format postcode for CSV letter rows
We are formatting the postcode here, because if we did it in template
preview, that could break flows like API and admin one-off, since
we are not validating postcode there yet, and format_postcode
needs a nice validated postcode.

We are not doing it in admin, as then we would have to either
rewrite the CSV file or pass data differently to API. First would
be nasty, second is a lot of overhead.

In the long run we might want to move postcode formatting to
template preview so that the postcode in letter preview looks the same
before and after user sends it, but now to get it out quickly it's better
to format the postcode here in the task.
2020-03-13 17:35:36 +00:00
Rebecca Law
3bf18d0ac3 Endpoint to return a ServiceContactList for a given id. 2020-03-13 17:21:59 +00:00
Rebecca Law
654e6fc657 New table and endpoints for service contact lists.
- Table to store meta data for the emergency contact list for a service.
- Endpoint for fetching contact lists for service
- Endpoint for saving contact list for service.

The list will be stored in S3. The service will then be able to send emergency announcements to staff.
2020-03-13 12:11:16 +00:00
David McDonald
f9751d6ebd Merge pull request #2746 from alphagov/fix-non-content-outside-errors
Undo bug for previewing precompiled letters
2020-03-11 15:29:10 +00:00
Chris Hill-Scott
87428685fb Merge pull request #2740 from alphagov/invited-by-notify
Let the Notify team invite people to an organisation
2020-03-11 14:52:05 +00:00
Chris Hill-Scott
4374ed6220 Merge pull request #2744 from alphagov/find_jobs_within_retention
Find only uploads within service data retention period
2020-03-11 14:51:56 +00:00
David McDonald
483c00b3a2 Undo bug for previewing precompiled letters
https://github.com/alphagov/notifications-api/pull/2742/files#diff-d9a6761afaff4a491e60b64f6063654fL265
introduced a change in behaviour which causes template preview to 500
for a precompiled letter that is invalid but not because the content is
outside the printable area.

The changes it back to the previous behaviour, where we b64encode and
utf-8 decode for a page that is invalid for reasons that are not content
outside the printable area, for example a non portrait a4 letter.

I didn't end up writing a unit test for this because I really can't
figure out the existing behaviour we expect for this use case. This
method is too big and complex but I'm confident by looking at the change
in the commit mentioned above that this puts behaviour back to how it
was. Manual testing also confirms the fix.

I've also taken this opportunity to improve two test names whilst I was
looking at things.
2020-03-11 14:34:12 +00:00
Pea Tyczynska
8b60e69157 Finding only jobs and letters within data retention works and tested 2020-03-10 15:53:56 +00:00
Rebecca Law
5902960516 Merge pull request #2741 from alphagov/make-sms-char-count-consistent
Update validators to use is_message_too_long()
2020-03-10 14:59:28 +00:00
Rebecca Law
a994e8fb6e Update validators to use is_message_too_long()
- update check_sms_content_char_count to use the SMSTemplate.is_message_too_long function, and updated the error message to align with the message returned by the admin app.
- Update the the code used by version 1 of the api to use the validate_template method.
  - I did find a couple of services still using the old api, however, this change should not affect them as I checked the messages being sent and they are not too long.
  - We will be sending a message to them to see if they can upgrade.
- Update the log message for authenication to include the URL - makes it easier to track if a service is using version 1 of the api.
2020-03-10 09:38:16 +00:00
David McDonald
d9243b8b8a When requesting a png for a single page, show overlay as appropriate
If the png page is invalid then show the overlay for that page
If the png page is not invalid, even if other pages are invalid, then
don't shown the overlay for that page

These keeps the behaviour were if you get the pdf for a pdf which has
invalid pages then the whole PDF is requested (not just a single page)
and all of the pages include the overlay

Tests have been improved to be more explicit about what we are testing
2020-03-09 14:54:58 +00:00
David McDonald
9eda30f4fd Refactor tests to be a bit more readable
Make arguments more verbose and have pytest params as inputs at the
start and expected things at the end
2020-03-09 14:48:33 +00:00
David McDonald
d168dd106e Add uncovered test cases
We want to know that the overlay is added regardless of which page
number you are requesting when a pdf contains pages that go beyond the
print area
2020-03-09 14:47:31 +00:00
Chris Hill-Scott
851435701f Merge pull request #2737 from alphagov/returned-letter-statistics
Add an endpoint to return returned letter stats
2020-03-05 16:11:09 +00:00
Chris Hill-Scott
6fd92c4931 Test for letters not returned recently
If you have some returned letters, but none in the last 7 days, we don’t
count how many you have in the last 7 days. But we should test to make
sure we’re not going to the database again.
2020-03-05 14:32:04 +00:00
Chris Hill-Scott
bdfeb08055 Let the Notify team invite people to an organisation
We want to start granting access to the org page. But it will be a bit
weird if the invites come from us personally, since the people we’re
inviting don’t know us.

It makes more sense, and sounds more official if the invites appear to
come from the ‘GOV.UK Notify team’ instead.
2020-03-05 12:34:17 +00:00
Chris Hill-Scott
02c824a980 Test for scenario when no returned letters exist 2020-03-05 11:10:32 +00:00
Chris Hill-Scott
70b2afa124 Rename method to be clear it’s recent-only 2020-03-05 11:10:32 +00:00
Chris Hill-Scott
9c03438a53 Add an endpoint to return returned letter stats
Currently the dashboard in the admin app pull the entire returned letter
summary for a service to calculate how many letters have been returned
in the last seven days.

Adding a separate endpoint for this purpose is better because:
- it’s a more efficient query
- it’s less data to send down the pipe
- it gives us a place to return the complete datetime, so the dashboard
  can be more precise about when the most recent report was
2020-03-03 17:16:54 +00:00
Chris Hill-Scott
b952b35714 Merge pull request #2726 from alphagov/launch-uploads
Give new services the upload letters permission
2020-03-03 14:38:32 +00:00
Chris Hill-Scott
aa69139fd1 Remove check on permission to upload letters
Soon enough every service will have this permission, and they won’t be
able to switch it off. So we should clean up our codebase and make it
so there’s no dependancy on a row existing in the permissions table.

This is the first step of that process for the API. Before we can remove
it, we have to stop checking from it. Next step will be to stop
inserting the permission, then finally remove it from the database.
2020-03-02 14:07:39 +00:00
Chris Hill-Scott
5c0e65a913 Merge pull request #2732 from alphagov/return-letter-upload-recipient
Return recipient for letter uploads
2020-02-28 15:29:39 +00:00
Pea M. Tyczynska
40ef0d0913 Merge pull request #2729 from alphagov/validate_send_file_by_email_contact_deets
All services can send files by email if they have set contact_link
2020-02-27 15:48:08 +00:00
Rebecca Law
7b0a3c68cd Fix bug on organisation-usage page.
The dict is initialised for all live services, but if the organisation has trial mode services they cause a key error.
2020-02-27 13:52:02 +00:00
Chris Hill-Scott
c7895df82c Return recipient for letter uploads
If your caseworking system always spits out files with the same name it
will be hard to differentiate them when looking at the uploads page.

Seeing who the letter was sent to will help you differentiate them.

We can’t do this until the API returns the recipient.
2020-02-27 13:19:51 +00:00
Rebecca Law
ba24fe449b Merge pull request #2723 from alphagov/organisation-usage
Organisation usage
2020-02-27 10:34:23 +00:00
Rebecca Law
c91f37ff4c Change the updates to only look at today, and not yesterday. 2020-02-26 17:38:20 +00:00
Chris Hill-Scott
0ac9a035d5 Merge pull request #2728 from alphagov/return-template-type-on-jobs
Return template type for jobs
2020-02-26 16:24:24 +00:00
Chris Hill-Scott
a513017f3c Remove use of ‘hence‘
Probably more straightforward language to say ‘in the future’
2020-02-26 16:16:20 +00:00
Chris Hill-Scott
57e671267c Return template type in uploads response
We need template type for the uploads response, which will eventually
supercede the jobs response. At the moment the page uses both.
2020-02-26 16:14:57 +00:00
Rebecca Law
95d48d40a9 Update error message, now includes the url where the service can add contact details. 2020-02-26 16:04:15 +00:00
Rebecca Law
f7a564a17c Add more realistic test
Add statsd
Fix imports
2020-02-26 11:21:33 +00:00
Pea M. Tyczynska
6d21515adf Apply suggestions from code review
Better grammar for our new error message.

Co-Authored-By: karlchillmaid <karl.chillmaid@digital.cabinet-office.gov.uk>
2020-02-26 10:45:39 +00:00
Chris Hill-Scott
ddb6fd33b0 Fix misnamed test
At some point[1] we moved from being able to schedule a job for up to 24 hours to 96 hours. The test was not renamed accordingly.

1. https://github.com/alphagov/notifications-api/pull/711
2020-02-26 08:46:02 +00:00
Rebecca Law
67c64a8715 Format the response to a more managable list.
Add a sort order
2020-02-25 17:34:03 +00:00
Pea Tyczynska
9a12d0e80e Update error message after discussion with Karl 2020-02-25 17:10:22 +00:00
Chris Hill-Scott
8601b13595 Return template type for jobs
This is so we can display letter jobs in a different way on the admin
app (because it doesn’t make sense for them to have failed/delivered
counts like it does for email and text message jobs).

As elsewhere we use `fields.Method` to avoid serializing the whole
template object.
2020-02-25 16:13:12 +00:00
Pea Tyczynska
ed1bc8d806 All services can send files by email if they have set contact_link 2020-02-25 16:11:53 +00:00
Chris Hill-Scott
b3c9680487 Give new services the upload letters permission
This will switch on this feature for new services.

After this we will:
- give existing services this permission with a database migration
- remove this permission from the codebase entirely so that everyone has
  this feature and can’t switch it off
2020-02-25 14:03:43 +00:00
Rebecca Law
a2d18f8598 Update the organsition usage endpoint to use the new query.
This endpoint may need to change, but we'd like to see how this performs, so we'll test this with a real data set. Then come back to make sure the format is correct and check for missing tests for the endpoint,
2020-02-25 09:29:50 +00:00
Rebecca Law
b1b457eea0 Only return the usage data for live services.
The list of trail mode services is only for platform admins, therefore the usage isn't needed for that page.
2020-02-24 14:23:05 +00:00