Commit Graph

264 Commits

Author SHA1 Message Date
Leo Hemsted
4ca23b2282 bring models in line with alembic
prevents new alembic scripts being pre-populated with index downgrades
2016-08-03 16:41:06 +01:00
Leo Hemsted
1617f058e2 rework get_fragment_count to not use ProviderStatistics
use NotficationHistory instead. Unfortunately this means the SQL
gets a bit gnarly, as we have to repeat notifications_utils'
`get_sms_fragment_count` functionality inside a SELECT 😱
2016-08-03 16:29:30 +01:00
Leo Hemsted
4ef084464d update notification_history table from notification_dao create/update functions
please ensure that any changes to notifications table happen through either dao_create_notification or dao_update_notification.
changed the notification status update triggered by the provider callbacks to ensure that sets updated_by and can update the history table.
also re-added the character_count so we can reconstruct billing data if needed.
2016-07-12 13:28:45 +01:00
Leo Hemsted
722699a72a Update notification_history table on insert/update of notifications
triggered via calls in dao_create_notification and dao_update_notification - if you don't use those functions (eg update in bulk) you'll have to update the history table yourself!
2016-07-12 13:27:31 +01:00
Leo Hemsted
47ef63adbe add notification_history table
table will be used for storing archival versions of notifications. It's an exact duplicate of notifications table, but with the following modifications:
* removed _personalisation
* removed to
* removed content_char_count

All foreign keys to other tables still exist. additionally, removed defaults (for id and created_at) since they'll be set when we create, and we should ensure that we don't forget about them when inserting/udpating this table.
2016-07-12 13:27:31 +01:00
Leo Hemsted
a5e488c035 add test api key type 2016-07-05 16:20:02 +01:00
Adam Shimali
19f2ccb594 Merge pull request #498 from alphagov/set-sms-sender-api
Set sms sender on service
2016-07-04 10:32:04 +01:00
Leo Hemsted
f992240192 make notification.key_type not nullable
set to 'normal' for all existing notifications, and all job notifications also created as 'normal' - so if your eg reporting service hits notify, it gets notifications created from both API calls and front-end csv jobs.
2016-07-01 16:36:11 +01:00
Adam Shimali
c29dd23702 Add sms sender to service to be used in sms templates
in place of default numeric short code.

If not present default short code is used.
2016-07-01 15:27:54 +01:00
Leo Hemsted
11093530f9 Merge pull request #485 from alphagov/api_user-cleanup
Api user cleanup
2016-07-01 10:58:18 +01:00
Rebecca Law
3f11447bc8 A small refactor to use the SMS_TYPE and EMAIL_TYPE in code rather that 'sms' or 'email' 2016-06-30 15:41:51 +01:00
Leo Hemsted
adbe02783d refactor authentication code
moved api_key secret manipulation (generating and getting) into
authentiation/utils, and added a property on the model, to facilitate
easier matching of authenticated requests and the api keys they used
2016-06-30 10:44:21 +01:00
Rebecca Law
25db1bce74 Use the notification types enum for the notifications.notification_type.
Reuse EMAIL_TYPE in template_types and notification_types.
2016-06-29 11:50:54 +01:00
Rebecca Law
60e159e3c0 Add notification_type to notification table.
It seems like an oversight not to include the notification type in the notifcation.
When updating statistics a query to the template table is required to get the type, this update will mean that query does not have to happen.
2016-06-29 11:23:02 +01:00
Rebecca Law
abb9135e35 Password changed at is defaulted to the current date when the user is created.
This PR set the users.password_changed_at column to not be nullable.
2016-06-28 11:24:08 +01:00
Leo Hemsted
e9482c7fe1 add new key_type table
* single-column static data table that currently contains two types: 'normal' and 'team'
* key_type foreign-keyed from api_keys
  - must be not null
  - existing rows set to 'normal'
* key_type foreign-keyed from notifications
  - nullable
  - existing rows set to null
* api_key foreign-keyed from notifications
  - nullable
  - existing rows set to null
2016-06-24 15:56:54 +01:00
Rebecca Law
3d3bff25a8 [WIP] updating notification to start in the created status 2016-06-21 15:51:30 +01:00
Rebecca Law
8caa688bf5 Add created as a status for notifications 2016-06-21 13:41:46 +01:00
Adam Shimali
731bb19a9c Template and personalisation content is now merged and returned with
notifications, when retrieved by notification id, or service id (i.e.
all notifications for service).

There is a new element returned at top level of notification json called
body, which is the template content merged with personalisation. This
is consistent with api to endpoint to create notification which returns
what was sent as 'body' in json response.

Merging of template with personalisation is done in the
NotificationStatusSchema.

Personalisation data in encrypted before storing in db.
2016-06-20 16:49:17 +01:00
Nicholas Staples
dd9a7f09c5 Twilio config variables removed. 2016-06-13 08:39:33 +01:00
Martyn Inglis
9aa727e0cf Add research mode to service/history tables
- added as a nullable boolean column.
2016-05-31 11:29:20 +01:00
Rebecca Law
885abcaf16 Make update notification status transcational.
Refactor methods for reusability.
2016-05-27 12:09:36 +01:00
Rebecca Law
25a1b7f31c Firetext does not have a status code for temporary-failure.
In order to set a message as temporary-failure, we check if it is in pending status first.
Otherwise a delivery receipt for failure is set to permanent failure.
2016-05-26 16:46:00 +01:00
Rebecca Law
dff60175a4 Add jobs.notifications_delivered and jobs.notifications_failed counts to the jobs table. 2016-05-23 15:44:57 +01:00
Nicholas Staples
0fe0c1d2b4 Added job row number to the notification for csv jobs. All tests passing. 2016-05-19 10:46:03 +01:00
Nicholas Staples
6e7383de33 Removed template subject uniqueness 2016-05-18 10:00:09 +01:00
Rebecca Law
191a79f27b Add new failure status for notifications. 2016-05-17 13:06:08 +01:00
Rebecca Law
8be3997bcf Merge branch 'master' into tech-failures 2016-05-17 12:05:48 +01:00
Rebecca Law
49db4e81d5 Add new notification status types for technical_failure, temporary_failure, permanent_failure 2016-05-17 11:46:28 +01:00
Adam Shimali
682ea55d9e [WIP] save reply to email address on service 2016-05-17 10:56:02 +01:00
Rebecca Law
c8c0f95dd2 Merge branch 'master' into add-template-version
Conflicts:
	tests/app/dao/test_notification_dao.py
2016-05-12 09:49:35 +01:00
Rebecca Law
f72f5aba05 [WIP]
Start to add template_version to jobs and notification
2016-05-11 17:04:51 +01:00
Martyn Inglis
b22c52131d Fixing up a couple of pull request comments
- python style if
- renamed the relationships
2016-05-11 15:36:17 +01:00
Martyn Inglis
09b3313ce3 Merge branch 'master' into primary-provider
Conflicts:
	tests/app/dao/test_provider_rates_dao.py
2016-05-11 14:04:15 +01:00
Nicholas Staples
03f15d6af9 Update now to utcnow. All tests passing. 2016-05-11 10:56:24 +01:00
Martyn Inglis
57e05feafb Updated the Provider stats and rates DAO objects to query based on the identifier in the ProviderDetails object.
- updated all tests
- changed teardown to leave provider details rows on end of individual tests
2016-05-06 09:09:47 +01:00
Martyn Inglis
fedbb27ffd Database changes to enable the new provider details table
- this will contain details as too which clients / notification types / priority etc for each delivery partner.

BREAKING CHANGE.

this pull request is ONLY the db changes. Everything is likely to break in the API until the code is updated.
2016-05-05 09:55:25 +01:00
Nicholas Staples
bedc20d0ff Fragment count endpoint added and all tests working. 2016-04-28 12:01:57 +01:00
Adam Shimali
f71b626089 Merge pull request #267 from alphagov/events
Endpoint for recording events in api.
2016-04-27 11:37:33 +01:00
Adam Shimali
dacbbfbf2f Endpoint for recording events in api.
An event has an id, a type and a blob of json attached.
2016-04-27 10:36:59 +01:00
Rebecca Law
94aab20317 Add created_by_id to jobs table.
The user logged in will be the user marked as creating the job.
The admin code already sends the created_by user when creating a job.
2016-04-26 16:15:34 +01:00
Nicholas Staples
e6cc3b1724 Added functionality to archive a template.
Renamed migration file.
2016-04-26 10:11:18 +01:00
Adam Shimali
9bb3214b1c Removed wandering code 2016-04-25 17:13:12 +01:00
Adam Shimali
24ea6f1637 Use short dates when selection notifications for deletion.
This means we will retain notifications for a full week and not
delete records that are 7 x 24 hours older than the time of the run of
the deletion task.

Also the task only needs to run once a day now, so I have changed
the celery config for the deletion tasks.
2016-04-25 16:12:46 +01:00
Nicholas Staples
b56e324a4c Working tests and provider stats table.
Fix for tests and import error.

Added tests and updated for code review comments.
2016-04-25 12:20:06 +01:00
Adam Shimali
74ac5b5f30 Added version history to api keys. This needed a bit of change
to create history to handle foreign keys better. There may yet
be a better way of doing this that I have not found yet in sqlalchemy
docs.
2016-04-21 14:47:58 +01:00
Nicholas Staples
3b1423a2ea Provider Statistics added.
Rates command added with a test.

Updated to include added migration.
2016-04-21 13:47:04 +01:00
Adam Shimali
054d8baa0a Changed notifications stats day column to date type from string. 2016-04-20 15:38:06 +01:00
Adam Shimali
a6a18c1a6f This approach uses part of sqlalchemy example history_meta code
adapted to recording inserts and updates.

This removes need to manually create history tables.

Our code still remains in control of when history records are
created.
2016-04-19 17:13:26 +01:00
Nicholas Staples
f681d40366 Character count added and tests passing.
Remove sql restriction for count to not be null.
2016-04-15 16:31:13 +01:00