Commit Graph

1848 Commits

Author SHA1 Message Date
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
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
Rebecca Law
18581c754a Add new endpoint to get available inbound number.
Add new endpoint to allocate a specific number to a given service.

This will allow the platform admin user to choose a number when setting the inbound_sms permission for a service.
2017-09-21 15:18:52 +01:00
Chris Hill-Scott
ee5888f07f Fix sending emails with no logo
Code was not expecting logo to be `None`, thereby causing the task to
throw an exception, and retry until eventually putting the email in
technical error (for services with org branding but no logo).
2017-09-21 13:37:57 +01:00
Chris Hill-Scott
8360b9a122 Merge pull request #1265 from alphagov/logoless-organsations
Make organisation logo nullable
2017-09-21 13:01:06 +01:00
Leo Hemsted
e18e78180e update letter tests to use correct service
previously they were using sample_service fixture under the hood, but
with full permissions added - this works fine, **unless** there's
already a service with the name "sample service" in the database. This
can happen for two reasons:

* A previous test didn't tear down correctly
* This test already invoked the sample_service fixture somehow

If this happens, we just return the existing service, without modifying
its values - values that we might change in tests, such as
research mode or letters permissions.

In the future, we'll have to be vigilant! and aware! and careful! to
not use sample_service if we're doing tests involving letters, since
they create a service with a different name now
2017-09-21 11:50:49 +01:00
Rebecca Law
0c9f16a8d1 Add id and service_id to the serialize method on ServiceEmailReplyTo 2017-09-21 10:21:32 +01:00
Rebecca Law
08fdcbfc67 Merge pull request #1266 from alphagov/use-reply-to-from-new-table
Use reply to email address from new table
2017-09-21 09:54:52 +01:00
Leo Hemsted
9afb2c36e7 Merge pull request #1241 from alphagov/letter-received
Letters are accepted, not created or sending
2017-09-20 16:51:31 +01:00
Leo Hemsted
4174c72f21 allow 'accepted' as a proxy for created + sending as well as 'failed' for the three failure types when querying the api 2017-09-20 15:30:14 +01:00
Rebecca Law
06ffac9a0f Merge branch 'master' into use-reply-to-from-new-table 2017-09-20 14:00:04 +01:00
Rebecca Law
3a5706994f Merge pull request #1258 from alphagov/add-multiple-reply-to-email-endpoints
Add multiple reply to email endpoints
2017-09-20 13:26:02 +01:00
Rebecca Law
877d8a2877 Remove the default value - expect it to always be set. 2017-09-20 12:20:12 +01:00
Rebecca Law
c6bf38e869 - is_default is required on the add_service_email_reply_to_request schema
- Added check that the service exists for the POST reply-to methods.
- Added tests
2017-09-20 11:58:18 +01:00
Leo Hemsted
f3b4a06a07 check both sms and email 2017-09-20 11:20:51 +01:00
Leo Hemsted
cb3379d0b6 rename received_by_notify to accepted
accepted is nice since it both implies that things look good, while
not being commital about next steps.
2017-09-20 11:20:51 +01:00
Leo Hemsted
18639354fa changed conftest to put underscores in sample_letter_template
this gets tests passing for now, but we'll need to make sure that
notifications.serialize handles letters with personalisation that
doesn't include underscores in future - for example, address_line_1
may also be addressline1 if someone uploaded a CSV
2017-09-20 11:20:51 +01:00
Leo Hemsted
10ceb0467e fix ordering to prevent random test failures 2017-09-20 11:20:13 +01:00
Leo Hemsted
4936fa384c return fake "received_by_notify" status for letter notifications
created and sending aren't quite as helpful for letters, since their
journey through notify and our providers is so different to emails/sms.
So instead, we should return estimated_dispatch_date (in a future PR)
and the status should just read received_by_notify
2017-09-20 11:20:13 +01:00
Chris Hill-Scott
bde6a9e131 Make organisation logo nullable
Now we have the org banner branding, not all organisations need a logo.
So it shouldn’t be an error to not provide one.
2017-09-20 11:06:16 +01:00
Rebecca Law
a53a0da414 [WIP] need to fix the tests 2017-09-20 10:45:35 +01:00
chrisw
f49eca5324 Add a non-GOV.UK banner option for email branding
Added an extra name, 'org_banner', for branding types into branding_type table
Added org banner into user model in database
Added checks for new branding type to ensure that the correct data is passed into the dict
Tested new checks in html email options
2017-09-19 14:40:22 +01:00
chrisw
9ecb666290 Fixed bug where a user with an organisation that wanted the GOVUK only branding ended up with both
If a user was to have an organisation selected in the email settings within the platform admin section, they would be sending emails that contained both the organisation's branding and GOV.UK's.

Fix adds a check to ensure that the branding dictionary does not contain organisation details if the the service branding settings is set to 'gov'
2017-09-18 11:33:47 +01:00
Chris Hill-Scott
2e9cecd385 Confirm no delivery estimate for emails and SMS
Only letters have a delivery estimate (which we calculate). This commit
adds a test to make sure this remains the case.
2017-09-18 11:02:16 +01:00