Commit Graph

4748 Commits

Author SHA1 Message Date
Richard Chapman
3f9a37d8a3 Updated the import for JSONDecodeError to import from from json.decoder
as it was failing on Jenkins.
2018-03-06 17:31:08 +00:00
Richard Chapman
e1e7f13f23 Added tests to ensure the parameter to the mock post request are the
correct type for the call as there are some that require json and some
binary. The additional checks ensure that that json decode either fails
or succeeds in the correct case.
2018-03-06 16:16:29 +00:00
Richard Chapman
77a3397ce5 Added option flag to the _get_png_preview method to determine if the
post method content is data or json format.
2018-03-06 15:35:00 +00:00
Richard Chapman
ed9936bba0 Fixed bug where the content header was not being passed onto the post
request. Changed data => json.

Added extra logging to display the error with more detail
2018-03-06 14:42:53 +00:00
Richard Chapman
d0df85a602 Fixed bug where the content header was not being passed onto the post
request. Changed data => json.

Added extra logging to display the error with more detail
2018-03-06 14:24:30 +00:00
Richard Chapman
bfdd385ba3 Tidied up imports. Removed local imports and made a global import so its
easier to maintain in future.
2018-03-05 17:08:09 +00:00
Richard Chapman
033a4099bc Added tests for all conditions for s_precompiled_letter.
* Added tests for hidden = true but name not precompiled
* Added test where name is precompiled but hidden is false
2018-03-05 16:57:48 +00:00
Richard Chapman
e91a0efc43 Refactored code to make it more maintainable and changed an error type
* Rather than an abort 404 returned a 500 and InvalidRequest so that the
error is more easily handled on the admin console. If the file is
missing but expected to be there is actually an internal error for admin
* Refactored the code to remove duplicate code in calls to template
preview by creating a new private method which is called with specific
parameters
2018-03-05 14:54:18 +00:00
Richard Chapman
a4feaba309 Added tests to tests for precompiled flow and refactored a little
* Added is_precompiled_letter method to letter/utils.py
* Added tests for letter/utils.py
* Added tests for the rest endpoint
* Moved the Precompiled name to a central location
* Added hidden field to the test method to create a template
2018-03-05 14:11:37 +00:00
Richard Chapman
a9a67ce542 Updated API to handle pre-compiled pdfs
* added a method to letter/utils.py to get the PDF document from the S3
bucket
* added the logic to return the pdf or to produce a png of the pdf
2018-03-02 14:54:28 +00:00
kentsanggds
2e958cfdd2 Merge pull request #1725 from alphagov/rc_add_get_template_preview
Add get template preview
2018-03-01 15:18:07 +00:00
Richard Chapman
42c1040604 Updated API to get it working with Admin.
* Added missing items from template which are required
* Returned the file as a JSON string with the file as a base64 encoded
string
* Updated tests to match teh desired format
2018-03-01 15:01:46 +00:00
Richard Chapman
4c8bc9f430 Added endpoint to get the letter preview from the template preview app
Is will allow the admin application to call into the api instead of
making the call itself. This will allow the api to make decision for
precompiled pdf without having to update the admin app.

- Added new endpoint
- Added tests for the endpoint
2018-03-01 15:01:46 +00:00
Rebecca Law
99a3dc8959 Merge pull request #1726 from alphagov/add-notification-id-to-log
Update log message
2018-03-01 12:19:48 +00:00
Rebecca Law
60b1c0ff5c Merge pull request #1728 from alphagov/remove-job-to-delete-letters
Suspend the `delete-letter-notifications` scheduled job.
2018-03-01 12:18:07 +00:00
Rebecca Law
be7989bbc9 Suspend the delete-letter-notifications scheduled job.
We have an issue with the provider. If we need to resend these letters, we need the notification.
2018-03-01 11:47:00 +00:00
Chris Hill-Scott
1eab7b7d4f Merge pull request #1723 from alphagov/no-priority-example
Remove priority flag from example templates
2018-03-01 11:11:10 +00:00
Rebecca Law
891a80addf Added notification id to the log message for upload pdf to make it easier to search for the letter notification in the logs. 2018-03-01 10:37:07 +00:00
Chris Hill-Scott
5134864a9e Merge pull request #1724 from alphagov/revert-1722-priority-one-off-2
Revert "Send one-off messages as fast as possible"
2018-03-01 10:34:54 +00:00
Chris Hill-Scott
9524e34ce1 Revert "Send one-off messages as fast as possible" 2018-03-01 10:17:59 +00:00
Chris Hill-Scott
f0d91bf1c5 Merge pull request #1722 from alphagov/priority-one-off-2
Send one-off messages as fast as possible
2018-03-01 09:38:09 +00:00
Chris Hill-Scott
08027947b2 Remove priority flag from example templates
Since we send all one off messages as priority
[now](https://github.com/alphagov/notifications-api/pull/1722), we don’t
need to explicitly mark the ‘Example text message template’ template as
being priority.

This commit retroactively removes the priority flag from these
templates, so that they can’t be reused to send other messages as
priority. I don’t think this is a real problem now, but worth cleaning
this up.

This query will hit approximately 827 templates.
2018-03-01 09:37:14 +00:00
Katie Smith
04ecea615b Merge pull request #1716 from alphagov/count-precompiled-letter-pages
Count the number of pages in pre-compiled letters
2018-02-28 16:50:38 +00:00
Katie Smith
bc619efc4e Count the number of pages in pre-compiled letters
We were already counting the billable units in PDFs that we generate.
We are now also counting the number of billable units in pre-compiled letters
and saving the result.
2018-02-28 16:14:25 +00:00
kentsanggds
0d2868625d Merge pull request #1720 from alphagov/ken-fix-failed-boto-mocks
Fix boto mocks in tests
2018-02-28 15:58:05 +00:00
Chris Hill-Scott
bc2e55a6b8 Send one-off messages as fast as possible
The vast majority of messages that are being sent one-off are
time-sensitive. A typical example is a caseworker on the phone who sends
a message at the end of the call. They normally wait until the message
has been delivered, so all the time they’re waiting is time when they
can’t be helping someone else.

What we don’t want to happen is for the messages they’re sending to get
stuck behind a big lump of GOV.UK Subscription emails or passport
reminder texts. I think the best way to do this is shift them onto the
priority queue.

We’re currently seeing queue sizes of up to 5,000 on the ‘normal’
queues; I don’t think there’s any risk of this change making the
priority queue more heavily-laden than this. Especially since the
traffic patterns of users sending one-off messages won’t be spiky.
2018-02-28 15:00:12 +00:00
Ken Tsang
b6401e4858 Fix boto mocks in tests
- was getting KeyError: 'Error' test failures due to the side_effect not generating enough information to be used in the ClientError class, this PR adds missing information.
2018-02-28 10:54:52 +00:00
Rebecca Law
d584ca4949 Merge pull request #1715 from alphagov/remove-deprecated-endpoint
Remove deprecated endpoints
2018-02-27 14:59:35 +00:00
Rebecca Law
12046ee85a There endpoint to check the token of an invitation for services and organisations have been merged.
This PR deletes the old endpoints.
2018-02-27 13:46:23 +00:00
Leo Hemsted
a87373571c Merge pull request #1714 from alphagov/reqs
bump requirements
2018-02-27 13:46:14 +00:00
Leo Hemsted
ab95a4501b bump requirements
notably, remove awscli and boto3 - they're both required by utils, and
are generating a lot of PR noise
2018-02-27 11:25:57 +00:00
kentsanggds
25d84af63e Merge pull request #1709 from alphagov/ken-fix-letter-serialization
Fix serialization on precompiled letter
2018-02-27 10:13:15 +00:00
Rebecca Law
6886cfcd82 Merge pull request #1710 from alphagov/org-user-endpionts
Fix db migration conflicts
2018-02-26 16:57:32 +00:00
Rebecca Law
0728c9f41a Fix db migration conflicts 2018-02-26 16:48:12 +00:00
Rebecca Law
7faf375375 Merge pull request #1695 from alphagov/org-user-endpoints
Organisation user endpoints
2018-02-26 16:27:01 +00:00
Ken Tsang
c14663d84a Fix serialization on precompiled letter
Postcodes are required for created letters, but not for precompiled, this fix allows postcodes to be None in the model.
As postcodes are still required for created letter they should be caught by validation schemas in the POST handler
2018-02-26 13:53:06 +00:00
Alexey Bezhan
8f08f691b2 Merge pull request #1708 from alphagov/non-nullable-hidden-templates
Set Templates.hidden column as non-nullable and filter hidden templates
2018-02-26 13:41:36 +00:00
Alexey Bezhan
984a5050db Don't return hidden templates in API service template responses
Brings back filtering hidden templates from the API responses.
2018-02-26 13:28:08 +00:00
Alexey Bezhan
dc99fe5ff3 Set Templates.hidden column as non-nullable
Sets hidden to false for all existing templates and makes column
non-nullable.
2018-02-26 13:28:08 +00:00
Alexey Bezhan
6ad868d22e Merge pull request #1707 from alphagov/dont-hide-hidden-templates-just-yet
Revert "Don't return hidden templates in API service template responses"
2018-02-26 11:54:01 +00:00
Alexey Bezhan
9b3a9a55c4 Revert "Don't return hidden templates in API service template responses"
Filtering out hidden templates requires all existing templates to
have `hidden` flag set, which can only be done by a migration after
the code that sets the flag to `False` by default for new templates
has been released.

This removes the filtering logic until the migration has been released.
2018-02-26 11:44:25 +00:00
Alexey Bezhan
b44f08bd0f Merge pull request #1706 from alphagov/nullable-template-hidden
Set Template.hidden as nullable before the new app code gets released
2018-02-26 10:56:06 +00:00
Alexey Bezhan
3a15a7e783 Set Template.hidden as nullable before the new app code gets released
Since the application code gets released after the migration setting
a new Template field as non-nullable prevents new templates from being
created by the existing application instances.

This splits the migration to set fields as nullable first and then
update existing records once the application code has been released.

0168 is modified not to run UPDATE query or set non-nullable flag in
staging and production. 0169 is added to rollback preview.
2018-02-26 10:46:20 +00:00
Alexey Bezhan
22382718e0 Merge pull request #1703 from alphagov/pre-compiled-letter-pdf-endpoint
Post pre-compiled letter PDF notification endpoint
2018-02-26 10:22:03 +00:00
Alexey Bezhan
19dbe7da8d Don't return hidden templates in API service template responses
Removes hidden templates from the service templates list and returns
404 when searching for a hidden template or template versions by ID.
2018-02-23 17:52:25 +00:00
Alexey Bezhan
d803b48d23 Return 400 response for invalid per-compiled letter content 2018-02-23 17:52:25 +00:00
Alexey Bezhan
bef91bcd99 Check for precompiled letter permission in the post notification 2018-02-23 17:52:25 +00:00
Alexey Bezhan
8971a5adce Upload pre-compiled letter PDF to S3
Pre-compiled letter endpoint uploads PDF contents to S3 directly
instead of creating a letter task to generate PDF using template
preview.

This moves some of the utility functions used by existing letter
celery tasks to app.letters.utils, so that they can be reused by
the API endpoint.
2018-02-23 17:52:25 +00:00
Alexey Bezhan
5327298371 Add a view function for pre-compiled PDF letters
Adds a separate view function that is registered under the same
route as existing letter POST notification.
2018-02-23 17:52:24 +00:00
Alexey Bezhan
e659253b01 Set Notify service user as the creator of Pre-compiled PDF template 2018-02-23 17:52:24 +00:00