Commit Graph

1870 Commits

Author SHA1 Message Date
Ken Tsang
dcf0d22d7b Added alert when job.notification_count doesn't match total notification for job
- Added log for when a job starts so that we will know when the processing of a job starts with the number of notifications
- Added dao method to get total notifications for a job id
- Added a test to check whether the number of notifications in the table matches the job notification_count
2017-10-10 15:04:55 +01:00
Richard Chapman
8c5771401a A few code style tweaks to adhere to standard for better maintainable code. 2017-10-06 17:08:06 +01:00
Richard Chapman
b311506f37 Updated send_to_providers.py to use the notification email_reply_to address if there is one present otherwise it uses the service email_reply_to so now users can choose a per notification email_reply_to address. 2017-10-06 16:58:32 +01:00
Richard Chapman
ce89a05038 Changes after review. Style changes to ensure consistency with the rest of the code base and changed the check of an asset message to be the full message to avoid any confusion in future. 2017-10-05 16:50:18 +01:00
Richard Chapman
7974e59eb7 Changes after review. Updates to style and import order to be more consistent with other code.
Added clarification to an error message to give better debugging information.
Removed using dao_get_reply_to_by_service_id in tests to be more consistent with other code and use the test db functions or remove the need for a call altogether making the code less complex.
2017-10-05 16:50:18 +01:00
Richard Chapman
d2168b7985 Added the mapping between notification and reply to email to the database and persisted the mapping when the request is received by the end point. the end point also checks if the reply to email id exists and if not returns an error. Also added tests to test the functionality. 2017-10-05 16:50:17 +01:00
Katie Smith
68d8999b1c Merge pull request #1294 from alphagov/add-new-letter-block-endpoints
Add new letter contact block endpoints (multiple addresses)
2017-10-05 15:58:51 +01:00
venusbb
5e2bf4cd32 Add new POST /<uuid:service_id>/letter-contact/<uuid:letter_contact_id> end point 2017-10-04 15:35:41 +01:00
Katie Smith
158e2ea181 Add endpoint to add new letter contact block
Added the '/<uuid:service_id>/letter-contact' service endpoint.
2017-10-04 15:31:45 +01:00
Rebecca Law
519c98615b Merge pull request #1288 from alphagov/return-service_sms_sender_value
Return service_sms_sender
2017-10-04 15:29:24 +01:00
Richard Chapman
2fbe492d5c [2/10] Allow API calls to specify the reply address option (#1291)
* Added service_email_reply_to_id to the POST /v2/notifications/email and a test to test the validator

* Caught NoResultFound exception in check_service_email_reply_to_id as it was not being caught when there there was no valid service_id or reply_to_id. Fixed failing tests which were not passing due to the NoResultFound exception and added further tests to check for the good path through the code and an test to check for an invalid service_id

* Added service_email_reply_to_id to the POST /v2/notifications/email and a test to test the validator

* Caught NoResultFound exception in check_service_email_reply_to_id as it was not being caught when there there was no valid service_id or reply_to_id. Fixed failing tests which were not passing due to the NoResultFound exception and added further tests to check for the good path through the code and an test to check for an invalid service_id

* Fixed code style in validators.py to confirm with rules
Update the name of email_reply_to_id to conform better with other attributes in the schema and the resultant code in post_notifications.py
Fixed code style in test_validators.py to confirm with rules
Added tests to test_post_notifications.py to test the email_reply_to_id being present and being incorrect, it being optional is being tested by other tests.

* Added service_email_reply_to_id to the POST /v2/notifications/email and a test to test the validator

* Added service_email_reply_to_id to the POST /v2/notifications/email and a test to test the validator

* Caught NoResultFound exception in check_service_email_reply_to_id as it was not being caught when there there was no valid service_id or reply_to_id. Fixed failing tests which were not passing due to the NoResultFound exception and added further tests to check for the good path through the code and an test to check for an invalid service_id

* Caught NoResultFound exception in check_service_email_reply_to_id as it was not being caught when there there was no valid service_id or reply_to_id. Fixed failing tests which were not passing due to the NoResultFound exception and added further tests to check for the good path through the code and an test to check for an invalid service_id

* Fixed code style in validators.py to confirm with rules
Update the name of email_reply_to_id to conform better with other attributes in the schema and the resultant code in post_notifications.py
Fixed code style in test_validators.py to confirm with rules
Added tests to test_post_notifications.py to test the email_reply_to_id being present and being incorrect, it being optional is being tested by other tests.

* Minor update after manual merge to fix check style rule break in test_validators.py where a single space was introduced.

* Updates after code review. Moved the template from the exception message as it was not required and updated the error message to match the field name in the sschema for better debugging and error identification.

* Fixed test after update of exception message
2017-10-04 14:34:45 +01:00
Rebecca Law
cefb74c732 Removed a test that should have been removed during the last merge 2017-10-04 13:49:01 +01:00
Rebecca Law
78a9d74c49 Merge branch 'master' into return-service_sms_sender_value 2017-10-04 13:29:05 +01:00
venusbb
212ce302c8 Add get letter contact by id endpoint
Added the GET /<uuid:service_id>/letter-contact/<uuid:letter_contact_id>
endpoint for returning a letter contact for a service with the letter contact id

Added the DAO for returning a letter contact by id
2017-10-04 12:26:38 +01:00
Katie Smith
1fa1ebb96f Add endpoint to return all letter contact blocks
Added the GET '/<uuid:service_id>/letter-contact' endpoint for returning
all letter contact blocks for a service.

Updated the DAO for service letter contacts to return the default letter
contact first.
2017-10-04 11:26:27 +01:00
Katie Smith
dede336b3b Update tests to not use letter contact block from services table
A few test updates were needed after rebasing onto master.
2017-10-03 13:35:09 +01:00
Rebecca Law
d1d655e23d Kept the test after all 2017-10-03 11:04:29 +01:00
Imdad Ahad
cb37ba5f78 Update schema to return default letter contact for a service 2017-10-03 10:31:21 +01:00
Imdad Ahad
4eebd9a83c Remove the letter_contact_block from the Service model 2017-10-03 10:31:21 +01:00
Imdad Ahad
d21d9cabd1 Use new default letter contact in the DVLA celery task 2017-10-03 10:31:15 +01:00
Rebecca Law
eff2a720ea Update post_allocate_inbound_number to set the service_sms_sender in the case when a service had the number, then it was set to inactive and now there is a request to turn it back on (or click allow inbound sms a couple of times on the front end) 2017-10-02 17:35:58 +01:00
Rebecca Law
0db39bfac8 Fix the unit tests.
I think there was some imports missed when resolving merge conflicts.
Also I'm not sure why the test_update_letter_notification_to_sent or error passed, I've updated them so they do pass.
2017-10-02 15:29:13 +01:00
Rebecca Law
d5c9174641 Merge branch 'master' of github.com:alphagov/notifications-api into return-service_sms_sender_value 2017-10-02 12:36:46 +01:00
venusbb
9a5addb896 Reverse codes that uses filtering of trial mode services 2017-10-02 12:00:52 +01:00
Chris Hill-Scott
2614d719d1 Merge pull request #1264 from alphagov/template-returns-placeholders
Return placeholders when getting a template
2017-10-02 11:21:46 +01:00
Rebecca Law
ba7cd79581 Created a get_default_sms_sender method, which returns the default sms_sender from the service_sms_sender table rather than service.sms_sender.
One step closer to removing services.sms_sender.

fix the unit tests
2017-10-02 10:29:00 +01:00
Katie Smith
f90a10ab38 Merge pull request #1277 from alphagov/imdad-katie-store-multiple-letter-contacts
[2/4] Upsert into ServiceLetterContact table when updating a service
2017-10-02 10:23:20 +01:00
Leo Hemsted
a74db5a80b Merge pull request #1280 from alphagov/letter-api-not-by-job
Letter api not by job
2017-09-28 10:55:58 +01:00
venusbb
9ad75ff726 Tests modified 2017-09-27 10:15:29 +01:00
Leo Hemsted
c97b130540 test dvla callback update tasks 2017-09-26 12:36:42 +01:00
Leo Hemsted
18ed90158e add tests for new noti dao function 2017-09-26 12:16:33 +01:00
Leo Hemsted
aaadf09562 add tests for new sched task 2017-09-26 12:03:06 +01:00
Leo Hemsted
b1928b928c update process_letter tests 2017-09-26 11:28:54 +01:00
venusbb
6a7013fa7a Enable Inbound sms IP blocking 2017-09-26 10:59:09 +01:00
Leo Hemsted
f3db920c71 remove jobs from letter api calls
we now no longer create a job. At the end of the post there is no
action, as we don't have any tasks to queue immediately - if it's a
real notification it'll get picked up in the evening scheduled task.

If it's a test notification, we create it with an initial status of
sending so that we can be sure it'll never get picked up - and then we
trigger the update-letter-notifications-to-sent-to-dvla task to sent
the sent-at/by.
2017-09-26 09:57:36 +01:00
Leo Hemsted
7dd3c1df5a set letter notifications to pending while notify-ftp does its stuff
this means that if the task is accidentally ran twice (eg we autoscale
notify-celery-worker-beat to 2), it won't send letters twice.

Additionally, update some function names and config variables to make
it clear that they are referring to letter jobs, rather than all letter
content
2017-09-26 09:57:35 +01:00
Leo Hemsted
f61ccd8ff0 add run_letter_notifications scheduled task
this task grabs all notifications that are sent via the API, and
are still in created - and sends them off to DVLA.
2017-09-26 09:57:35 +01:00
Imdad Ahad
f0784109a1 Upsert into letter contact table when updating a service's letter contact block 2017-09-25 16:01:24 +01:00
Imdad Ahad
3977574ef1 Add methods to add/update letter contacts for a service that handle defaults properly 2017-09-25 15:46:01 +01:00
Rebecca Law
0fa16cc9d1 Merge pull request #1270 from alphagov/select-inbound-number-to-assign
Select an inbound number for a service
2017-09-25 14:17:36 +01:00
Imdad Ahad
fa3f4f3c20 Add dao to store letter contacts and upsert 2017-09-25 12:26:29 +01:00
Rebecca Law
b195257d94 Added another test 2017-09-25 11:14:29 +01:00
Rebecca Law
64db8cb18d Merge branch 'master' into select-inbound-number-to-assign 2017-09-25 11:13:12 +01:00
Chris Hill-Scott
55d185f50d Return metadata about placeholders
In the future, we may want to return additional information about
placeholders.

We came up with three possible formats:
1. list of `dict`s, eg `[{'name': 'first name', 'required': True}]`
2. `dict` of `list`s, eg `{'required': ['first name']}`
3. `dict` of `dict`s, eg `{'name': {'required': True}}`

I don’t like 1. because it’s harder to traverse if all you want is the
name of the placeholders, and suggests that you could have two
placeholders with the same name (which you can’t). I don’t like 2.
because it only lets the data be sliced by one dimension (unless the
inner lists aren’t exclusive, in which case you’d need to filter
duplicates when just listing placeholders).

I think 3. has the two advantages of:
- represents that personalisation is unique, ie you can’t pass back in
  two different values for the same key
- is forward compatible, ie we can add many more properties of a
  placeholder without breaking anything

So this commit implements 3.
2017-09-22 16:42:16 +01:00
venusbb
4e991c26a2 Progress: Filtered day completed 2017-09-22 15:39:53 +01:00
Rebecca Law
03ea09fd6a Add order by in the dao_get_reply_to_by_service_id() 2017-09-22 10:02:59 +01:00
Chris Hill-Scott
fa8e4b29f2 Return placeholders when getting a template
> Currently when retrieving a template via one of the clients, we do
> not return the personalisation fields that are required for that
> template.
>
> This is useful for services who want to perform template validation on
> their own systems. A service user has also requested this.

– https://www.pivotaltracker.com/story/show/150674476

This commit adds an extra attribute to the JSON response containing an
array of the placeholder names. This key is called "personalisation",
to match the argument that developers use to pass in the values of
placeholders.
2017-09-22 10:00:23 +01:00
Rebecca Law
9bc1d13785 Merge pull request #1272 from alphagov/get-reply-to-by-id
New endpoint to fetch a single reply-to email address by id
2017-09-22 09:41:19 +01:00
Rebecca Law
795bd4271c New endpoint to fetch a single reply-to email address by id 2017-09-21 17:02:58 +01:00
Ken Tsang
366d07dbbe Add ServiceLetterContact data model and script 2017-09-21 16:08:49 +01:00