Commit Graph

696 Commits

Author SHA1 Message Date
Nicholas Staples
01f616eeac Fix all tests. 2016-03-02 11:10:52 +00:00
Nicholas Staples
6f689a187e Merge remote-tracking branch 'origin/master' into update_permission_endpoints 2016-03-02 10:44:38 +00:00
Chris Hill-Scott
fa4b2e16e7 Remove CSV utils
These are in the utils repo since https://github.com/alphagov/notifications-utils/releases/tag/0.2.1
2016-03-02 08:59:34 +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
Nicholas Staples
47c4368007 Merge with master. 2016-03-01 17:18:46 +00:00
Rebecca Law
a2b1dc0432 Merge pull request #115 from alphagov/accept-invite
[WIP] Start of api for accepting invite.
2016-03-01 15:57:52 +00:00
Adam Shimali
ac9adc292b [WIP] Change status code to 404 rather than 400. 2016-03-01 15:51:22 +00:00
Adam Shimali
993bdc8055 [WIP] use correct dao function for adding user to service.
Check for no user returned from user dao and return correct
error message.
2016-03-01 15:36:31 +00:00
Adam Shimali
9fe08d480c Merge pull request #114 from alphagov/cancel-invited-user
New endpoint to update invited user.
2016-03-01 15:17:03 +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
Nicholas Staples
918d40cc9d Functionality added and all tests working. 2016-03-01 14:21:28 +00:00
Adam Shimali
3b66745677 [WIP] Start of api for accepting invite. 2016-03-01 14:13:38 +00:00
Rebecca Law
98c9ba14f7 New endpoint to update invited user.
Can be used to update status on invited user.
2016-03-01 13:33:20 +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
Nicholas Staples
7d43b4265f Merge and fix conflicts. 2016-03-01 11:59:50 +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
Nicholas Staples
47ac0b8a98 Fixed some tests. 2016-02-29 18:32:25 +00:00
Rebecca Law
6f338f17ac Merge branch 'master' into invitation
Conflicts:
	scripts/run_celery.sh
2016-02-29 16:14:35 +00:00
Rebecca Law
9f6255ac94 Add subject line to the invitation email. 2016-02-29 16:12:12 +00:00
Rebecca Law
3879350c12 Send email invitation to invited user 2016-02-29 15:56:00 +00:00
Nicholas Staples
8ad13b6356 Manage template permission added. All tests passing. 2016-02-29 15:21:35 +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
Rebecca Law
df278a8e6e Email invitation to an invited user.
New celery task to send the email.
2016-02-29 13:21:12 +00:00
Nicholas Staples
2cf2b51cd9 Fix for git commit review. 2016-02-29 11:50:43 +00:00
Nicholas Staples
9b73b0d9f8 Default permissions added on service creation. All tests working. 2016-02-26 17:11:30 +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
Rebecca Law
ff6cad1acf Merge branch 'master' into service-not-found-returns-404
Conflicts:
	app/errors.py
2016-02-25 15:33:53 +00:00
Rebecca Law
0f333de2cc Merge branch 'master' into service-not-found-returns-404 2016-02-25 15:16:56 +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
99c9cd608c [WIP] changed dao query to use .first and return specific not found
error message from rest view method.
2016-02-25 12:13:25 +00:00
Rebecca Law
67af351f26 Fix get_users_by_service to return 404 if service does not exist.
Refactored service/rest.py so that all methods are returning a properly formatted error message so that the error message can deal with the response.
Refactoed errors.py to properly format the error message.
2016-02-25 12:11:51 +00:00
Martyn Inglis
a3a9d673a6 Merge branch 'master' into celery-jobs 2016-02-25 12:06:53 +00:00
Martyn Inglis
0b63477e49 Removed now unused notification for job endpoints
- this is now handled in the tasks
2016-02-25 11:35:32 +00:00
Martyn Inglis
44632c36d3 Add sender name to the notification
- also ensure that the created time is handled properly
2016-02-25 11:23:04 +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
NIcholas Staples
064fec5ad5 Merge pull request #95 from alphagov/get-users-for-service
New endpoint to get users for service id.
2016-02-24 14:29:39 +00:00
Adam Shimali
e6fe10cbdc [WIP] added endpoint and dao to create invites for users.
Droped token as later code to send email invite can generate
timebased url to send to user. That can then be checked
against configurable time threshold for expiry. Therefore
no need to store a token.
2016-02-24 14:18:56 +00:00
Martyn Inglis
1667f82df1 Removed some unused template dao methods 2016-02-24 11:51:02 +00:00
Martyn Inglis
6ac6a64b46 Tests for email job notifications endpoint 2016-02-24 11:44:11 +00:00
Martyn Inglis
8389976250 Use service ID, not from token to build notification 2016-02-24 11:11:02 +00:00
Rebecca Law
f1fdfbb308 Return empty list when there are no users for the service.
Added a test for when there are no users for the service.
Added a test_url_for - do we want to add this test and use url_for in our tests?
Or explictly write the url in the test?
2016-02-24 10:30:00 +00:00
Martyn Inglis
b0609b1813 More refactors
- single base method to send notifications
- knows about service id (present if job based)
- knows about jobs - if needed
- knows about type

Does the right thing

Was lots of shared code around error checking now in one place.
2016-02-24 09:55:05 +00:00
Martyn Inglis
0007c69972 Restored code to share sms creation logic between:
- sms for API calls
- sms for Jobs
2016-02-24 09:23:21 +00:00