Commit Graph

59 Commits

Author SHA1 Message Date
NIcholas Staples
528f570ab6 Merge pull request #141 from alphagov/capture-aggregate-data
Capture aggregate data
2016-03-08 17:54:39 +00:00
Martyn Inglis
f5f50e00ff New notification stats table
- to capture the counts of things that we do
- initial commit captures when we create an email or sms

DOES NOT know about ultimate success only that we asked our partners to ship the notification

Requires some updates when we retry sending in event of error.
2016-03-08 15:23:19 +00:00
Chris Hill-Scott
157b385327 Use validation of recipients from utils
This was added to utils in 5914da74f1

This means that:
- we are doing the exact same validation in the API and admin app
- we are actually validating phone numbers for the correct format (hence all the
  changes to the tests)
2016-03-08 09:47:21 +00:00
Martyn Inglis
800afc9e44 Ensure restricted service are respected by tasks:
This is checked on 3rd party API calls, but jobs (CSV files) were able expected to only allow valid files.

Change in tack means we want to have restricted notification failures reported in the UI.
2016-03-03 12:05:18 +00:00
Nicholas Staples
ebec54cb80 Permission enums corrected, all tests passing. 2016-03-02 15:34:26 +00:00
Rebecca Law
3fd3aa5b3e Merge pull request #119 from alphagov/update_permission_endpoints
Update permission endpoints
2016-03-02 14:33:18 +00:00
Nicholas Staples
01f616eeac Fix all tests. 2016-03-02 11:10:52 +00:00
Chris Hill-Scott
d6f7c7d1c9 Replace placeholders before sending a message
This commit replaces placeholders in a template with the user’s data, using
the Template class from utils
(https://github.com/alphagov/notifications-utils/tree/master/utils#template)

It also extracts the personalisation data from the CSV, taking account of the
different column headings that SMS and email CSVs will have.

At the point of creating the task to send an individual messages, validation of
the placeholders matching the template is assumed to have been done either:
- in processing the CSV in the admin app
- in the endpoint for the API call

No exceptions should be raised at this point.
2016-03-02 08:59:34 +00:00
Chris Hill-Scott
68eaacaafb Accept and validate personalisation
This commit allows the send notification endpoint to accept an extra parameter,
`personalisation`, the contents of which will be used (later) to replace the
placeholders in the template.

It does validation in the following places:
- at the schema level, to validate the type and (optional) presence of
  personalisation
- at the endpoint, to check whether the personalisation provided matches exactly
  the placeholders in the template

It does not do validation when processing CSV files, as these are assumed to
already have been validated by the admin app.

It explicitly does not persist either the names of the placeholders (these
should always be derived from the template contents unless it really becomes a
performance concern) or the values of the placeholders (because they might be
personal data).
2016-03-02 08:59:34 +00:00
Rebecca Law
dd503e7f14 Merge pull request #113 from alphagov/fetch-notifications-endpoints
Fetch endpoints for notifications
2016-03-01 15:16:54 +00:00
Martyn Inglis
6d345c1dfc Fixed ordering of the notifications test
- was backwards
2016-03-01 14:58:27 +00:00
Martyn Inglis
c5a993ead1 Fetch endpoints for notifications
- includes check on token type to ensure clients can perform admin style fetches
2016-03-01 13:30:10 +00:00
Rebecca Law
ecbfbbc6b0 Fix bug in PermissionDAO
Refactor user/test_rest
Remove conftest/sample_admin_service
2016-03-01 10:34:27 +00:00
Adam Shimali
59aec1939c [WIP] invited user now has comma separated permission values
stored against it so that user can be created with correct
permissions.
2016-02-29 14:05:02 +00:00
Nicholas Staples
75b9f77f92 user permissions now returned with the user object and all tests passing. 2016-02-26 15:57:24 +00:00
Nicholas Staples
16e1ecb134 Working permissions and all tests passing.
Remove print statements.

Fix for review comments.
2016-02-26 15:00:29 +00:00
Martyn Inglis
b213c3fa3c Merge branch 'master' into celery-jobs
Conflicts:
	tests/app/conftest.py
2016-02-25 15:10:39 +00:00
Adam Shimali
3b11cfc8e5 Fix for intermittent failure 2016-02-25 12:27:42 +00:00
Martyn Inglis
34f2016b19 Reorder DB scripts after merge from master 2016-02-25 12:19:48 +00:00
Adam Shimali
883ad02c25 [WIP] added dao and rest endpoint for retrieving invited users
by service and by id.
2016-02-25 11:22:36 +00:00
Martyn Inglis
10a764a2c1 Renamed the header of the CSV to 'to' from 'number' to allow for email jobs
- added new columns to Job and Notification to capture the start/end dates accurately
2016-02-25 09:59:50 +00:00
Martyn Inglis
b3884e2d6c Move job processing into celery
- brings boto S3 into new AWS folder
- CSV processing utils method

Rejigs the jobs rest endpoint - removes some now unused endpoints,

Calls to the task with the job, job processing in task, delegating SMS calls to the sms task
2016-02-24 17:12:30 +00:00
Martyn Inglis
1667f82df1 Removed some unused template dao methods 2016-02-24 11:51:02 +00:00
NIcholas Staples
8de4ae5cf2 Merge pull request #91 from alphagov/send-email-from-templates
Send Email via the API
2016-02-23 13:18:45 +00:00
Martyn Inglis
b01782bbe6 Send Email via the API
- uses the new subject/email from fields present on the templates / service tables
- brings the send email api call into line with the sms one.
- same fields (to/template_id)
- same rules regarding restricted services
- wired in as a task into celery

Requires
- new celery queue
- new env property (NOTIFY_EMAIL_DOMAIN)
2016-02-22 17:17:29 +00:00
Adam Shimali
c36b64c91b Added notification count to jobs. 2016-02-22 14:57:33 +00:00
Martyn Inglis
886b206d63 Merge branch 'master' into email-templates
Conflicts:
	app/user/rest.py
	tests/app/user/test_rest.py
2016-02-22 13:12:24 +00:00
Martyn Inglis
cc720b137f Merge branch 'master' into email-templates
Conflicts:
	app/user/rest.py
2016-02-19 17:33:28 +00:00
Martyn Inglis
dc294c32ae Fix all other dependant classes that are affected by the DAO / Service / Model changes 2016-02-19 15:54:11 +00:00
Nicholas Staples
0396148853 Permissions added. 2016-02-19 14:47:45 +00:00
Rebecca Law
c1df61a7d4 Use celery to send the email verification code. 2016-02-18 09:52:27 +00:00
Rebecca Law
9073814d9f I have an issue with the test, not sure why? 2016-02-17 17:48:23 +00:00
Rebecca Law
d022d036dc Celery task to send the sms verify code.
Each celery task will use it's own queue.
2016-02-17 15:41:33 +00:00
Martyn Inglis
a2341be0e2 Don't send the SMS if we have failed to save in the database 2016-02-16 17:42:04 +00:00
Martyn Inglis
e42da7dd54 Fixing up tests to validate the call to the celery tasks.
- mocker used to test call or otherwise of the task
- no new tests just a spring clean
2016-02-16 14:06:56 +00:00
Nicholas Staples
bd947d0743 Merge remote-tracking branch 'origin/master' into remove_alpha_client_from_api 2016-02-09 15:54:21 +00:00
Adam Shimali
e5e049d735 Added service and template relationship to notification model.
This makes it more consistent with other model classes with respect
to marhmallow serialisation/deserialisation.
2016-02-09 12:48:27 +00:00
Adam Shimali
c7121be5a2 [WIP] New model class and dao for notification. This will be used for
recording status and outcome of sending notifications.
2016-02-09 12:03:40 +00:00
Nicholas Staples
2fda7ee59b Alpha client removed from code. Tests fixed but will wait till other notifications jobs are done before creating a pull request. 2016-02-09 11:38:57 +00:00
Rebecca Law
b5c662eca8 Change services.id to a UUID
Ideally all the primary keys in the db would be UUID in order to guarantee unique ids across distributed dbs.
This updates the services.id to a UUID. All the tables with a foreign key to the services.id are also updated.
The endpoints no longer state a data type of the <service_id> path param.
All the tests are updated to reflect this update.

The thing to pay attention to is the 0011_uuid_service_id.py migration script.
This commit must go with a commit on the notifications_admin app to keep things working.
There will be a small outage until both deploys have happened.
2016-02-02 14:22:22 +00:00
Rebecca Law
42a4c8b0b1 Add sms notifications from a service to a queue. 2016-01-27 17:42:05 +00:00
Rebecca Law
daff1c3f53 Add queue name to service table.
Set queue name when creating the service
2016-01-27 14:18:11 +00:00
Rebecca Law
5dc48f8a01 Updated send user code to use an optional to field to send emails
Added tests for send_user_code
2016-01-27 11:51:02 +00:00
Nicholas Staples
a9fe6ad469 Working code and tests. 2016-01-22 14:43:30 +00:00
Nicholas Staples
6b035cd324 All tests working, second time around. 2016-01-21 17:29:24 +00:00
Rebecca Law
1db57dca8c Allow for multiple api keys for a service. 2016-01-19 18:25:21 +00:00
Rebecca Law
15b2d414cc Updates from review comments:
Update api_key relationship.
Check that id in dict exists before deleting it
2016-01-19 13:11:22 +00:00
Rebecca Law
4fc5c34320 Change Tokens to ApiKey
Added name to ApiKey model
2016-01-19 12:13:47 +00:00
Adam Shimali
f839bae1f5 Add rest of user model fields to api.
First step to moving user interactions to api.
2016-01-19 11:39:59 +00:00
Adam Shimali
f3b6769193 Add convenience fields to job to make processing
easier.
2016-01-16 10:14:48 +00:00