Commit Graph

3359 Commits

Author SHA1 Message Date
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
Rebecca Law
18f272dc2b Add queries to handle returning usage for all services associated to a given organisation. 2020-02-24 11:28:42 +00:00
David McDonald
42f02c8c24 Merge pull request #2717 from alphagov/collate-pdf
Look at all previous days when sending letters
2020-02-24 10:16:18 +00:00
Rebecca Law
1f143a0abf Merge pull request #2719 from alphagov/billing-dao-fix
Billing dao fix
2020-02-24 09:41:09 +00:00
David McDonald
2c41b21ddf Remove unnecessary code and unrelevant comment 2020-02-21 16:42:37 +00:00
David McDonald
2cd05dea89 Make test DRY 2020-02-21 16:27:15 +00:00
David McDonald
6f663268e1 remove unneeded mock 2020-02-21 16:19:47 +00:00
David McDonald
e6767590d4 Change function and task name to be more accurate
Will require us to change a cronitor set up
2020-02-21 15:01:19 +00:00
David McDonald
148a5ab456 Refactor dates being passed around
I believe this way is nicer to read, we don't have to change between
datetimes and strings and back.
2020-02-21 15:01:19 +00:00
David McDonald
6226d9e122 Don't send test letters to dvla to print 2020-02-21 15:01:19 +00:00
David McDonald
7578e01b3b Test cases explicitely
In previous tests we check that we can deal with files that end in `pdf`
in various forms of upper and lowercase. I've moved the testing of this
behaviour into it's own test so that's explicit and not just implied
that we care about behaviour on the casing of filenames.

Note however that s3 is case sensitive and we upload all our files in
upper case so technically we'd never expect to see a file ending in
`pdf`. I've updated some of our test data to reflect this but didn't
bother doing it everywhere. I've left the test in anyway but it could be
argued that is is redundant as we don't ever expect to see that case
anyway.
2020-02-21 15:01:19 +00:00
David McDonald
5c5eb8a96a Remove unneeded check that notification is in created state
We instead rely on the fact that only files being passed into this
function we already know are in the created state
2020-02-21 15:01:19 +00:00