Commit Graph

7018 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
Chris Hill-Scott
7636c4225d Merge pull request #2727 from alphagov/ship-uploads
Give existing services upload letters permission
2020-03-11 16:22:15 +00:00
Chris Hill-Scott
e12829e56e Give existing services upload letters permission
This gives the feature to all existing users.
2020-03-11 15:31:53 +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
David McDonald
0ba0bdca15 Merge pull request #2742 from alphagov/overlay-sometimes
Only add overlay for pages which are invalid for precompiled letters uploaded via the API
2020-03-10 13:54:22 +00:00
David McDonald
34d571405e Refactor of logic to make code more readable
Functionality remains as it was
2020-03-10 13:38:20 +00:00
Katie Smith
d0cb5db19b Merge pull request #2743 from alphagov/international-letters-permission
Add international_letters service permission
2020-03-10 10:12:54 +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
Katie Smith
a9abc63297 Add international_letters service permission 2020-03-09 15:42:07 +00:00
David McDonald
08ec06295a Merge pull request #2738 from alphagov/pyup-scheduled-update-2020-03-04
Scheduled weekly dependency update for week 09
2020-03-09 15:41:29 +00:00
David McDonald
a8f2aa2022 run make freeze-requirements 2020-03-09 15:29:26 +00:00
pyup-bot
6d22c8fe14 Update marshmallow-sqlalchemy from 0.22.2 to 0.22.3 2020-03-09 15:29:26 +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
David McDonald
296a8b1ed7 Merge pull request #2736 from alphagov/tidy-makefile
Tidy makefile
2020-03-09 11:58:16 +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
David McDonald
2a4b1a58f8 Merge pull request #2739 from alphagov/statsd-prefix
Remove unused statsd_prefix variable
2020-03-05 13:43:47 +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
David McDonald
f56795655e Remove unused STATSD_PREFIX variable
We moved from sending statsd metrics to hosted graphite to sending to
one that is running on the paas. Therefore we no longer need to send
statsd metrics to a particular prefix at the statsd app as it is only
receiving statsd metrics from our apps (not other users like would have
been the case with HostedGraphite).

This should change no behaviour as the only place the environment
variable was being used was in the gunicorn config and it was an empty
string which is the default behaviour anyway as per:
https://docs.gunicorn.org/en/stable/settings.html#statsd-prefix
2020-03-05 10:41:26 +00:00
Chris Hill-Scott
8c47d07845 Optimise method to prevent redundant counting
If we know that the most recently returned letter was reported more than
7 days ago then we know, without having to go to the database again,
that the count of returned letters in the last 7 days is 0.
2020-03-05 10:00:30 +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
223ec1360c Merge pull request #2735 from alphagov/dont-check-upload-letter-permission
Remove check on permission to upload letters
2020-03-03 12:04:01 +00:00
David McDonald
5a3110c5ee Reorganise makefile
Also remove `check-env-vars` which is not being used anywhere
2020-03-03 11:51:50 +00:00
David McDonald
07c7e1d91d Remove make commands we don't use
These are either just generally not being used or they've been
superseeded by commands manually written in concourse
2020-03-03 11:51:05 +00:00
David McDonald
218ef97e14 Remove jenkins related code 2020-03-03 11:49:28 +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
Chris Hill-Scott
f57b5445c3 Pass through template_type from DAO
The DAO sets template type to `None` for one-off letters, so the REST
method doesn’t need to do any special handling of it.
2020-02-28 09:58:13 +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
ab2e44889e Merge pull request #2733 from alphagov/fix-organisation-usage-bug
Fix bug on organisation-usage page.
2020-02-27 15:06:12 +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
David McDonald
54491b372d Merge pull request #2731 from alphagov/pyup-scheduled-update-2020-02-26
Scheduled weekly dependency update for week 08
2020-02-27 10:15:28 +00:00
Rebecca Law
c91f37ff4c Change the updates to only look at today, and not yesterday. 2020-02-26 17:38:20 +00:00
Leo Hemsted
0e7049d49a freeze-requirements 2020-02-26 17:21:42 +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
94942f0928 Merge pull request #2730 from alphagov/24-2-96
Fix misnamed test
2020-02-26 16:24:17 +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