Commit Graph

275 Commits

Author SHA1 Message Date
Leo Hemsted
350133e6db ensure created_by_id is being persisted correctly
(also make sure it's well tested 🎉 )
2017-06-23 15:56:47 +01:00
Leo Hemsted
a1e570dea7 persist created_by_id when using the one off notification endpoint 2017-06-20 12:06:49 +01:00
Leo Hemsted
9f307fd1c5 add created_by to notifications
this is so one-off notifications can be tied to a user
(jobs have a created_by, and api notifications don't make sense
 to have one)
2017-06-20 11:51:17 +01:00
Rebecca Law
3a66027d6a Refactor ApiKeys.secret and ServiceInboundApi.bearer_token to use the same encryption method and get rid of the duplicate code. 2017-06-19 14:32:22 +01:00
Rebecca Law
6202da7dea Update model to remove the string length restriction.
Moved logic to the dao from the endpoint.
2017-06-19 12:25:05 +01:00
Rebecca Law
effb99dca8 Add fetch request for service inbound api.
Add unique constraint on service_id for service_inbound_api.
2017-06-15 16:19:12 +01:00
Rebecca Law
828d5cd493 New table to store the inbound api information for a service. The table is versioned.
There is a new endpoint to create the inbound api and one to update it.
2017-06-15 11:32:51 +01:00
Rebecca Law
b186cad046 Add a new table to store the api information for a service inbound sms message.
Including:
 - url to push the inbound sms to
 - bearer_token to be added to the header of the request.

The services will be expected to manage these properties.
2017-06-13 15:27:13 +01:00
Martyn Inglis
9bbb3c6a56 Merge branch 'master' into firetext-inbound-sms-not-null-provider
Conflicts:
	tests/app/db.py
2017-06-09 11:56:32 +01:00
Rebecca Law
03c6e74c46 Merge pull request #1024 from alphagov/job-stats-for-dashboard
Change the job_statistics table structure
2017-06-08 13:19:15 +01:00
Rebecca Law
1b4097cb16 Add three new columns to job_statistics for sent, delivered and failed.
A job only ever has one notification type.
This is the first deploy, where the columns are added and populated.

Next a data migration will happen to populate these new columns for the older jobs that do not have the values set.
Then we stop populating the old columns and remove them.
This refactoring of the table structure will make the queries to the table much easier to handle.
2017-06-07 11:15:05 +01:00
Martyn Inglis
75bf693f44 Add the yearly free limit to the service model.
This allows us to reference it across the API code base and return it in the API.

But not currently attached to the service DB model - a static method on the class.
2017-06-06 14:49:05 +01:00
Martyn Inglis
687b8443d1 Merge branch 'populate_provider_column' into firetext-inbound-sms-not-null-provider 2017-06-05 11:57:39 +01:00
Martyn Inglis
f15d235d1e Merge branch 'master' into firetext-inbound-sms 2017-06-05 11:33:53 +01:00
Martyn Inglis
400096520d Not null the provider column on the inbound SMS table. 2017-06-02 16:51:27 +01:00
Martyn Inglis
012f8d2675 Adds provider onto the inbound sms table so we know where this came from. 2017-06-02 16:37:57 +01:00
Leo Hemsted
ef52337d85 add inbound sms api
two endpoints:
* get all inbound sms for a service (you can limit to the X most
  recent, or filter by user's phone number [which will be normalised])
* get a summary of inbound sms for a service - returns the count of
  inbound sms in the database, and the date that the most recent was
  sent
2017-06-02 15:20:18 +01:00
Rebecca Law
9d80bdc70f Merge branch 'master' into letters-billing-table
Conflicts:
	app/models.py
2017-06-02 14:47:28 +01:00
Martyn Inglis
c57e2a6894 Merge branch 'master' into inbound-sms
Conflicts:
	app/notifications/receive_notifications.py
	tests/app/notifications/test_receive_notification.py
2017-06-01 15:56:33 +01:00
Martyn Inglis
a60d40bbc0 Merge branch 'master' into remove-nasty-query-from-dashboard
Conflicts:
	tests/app/service/test_rest.py
2017-06-01 14:47:00 +01:00
Leo Hemsted
3e47519045 Merge pull request #1006 from alphagov/revert-1001-revert-988-non-null-again
Revert "Revert "Remove nulls from sms_sender""
2017-06-01 13:14:03 +01:00
Martyn Inglis
7f65aa3eef Merge branch 'master' into remove-nasty-query-from-dashboard
Conflicts:
	app/service/rest.py
	tests/app/service/test_rest.py
2017-06-01 13:11:54 +01:00
Leo Hemsted
d33698216c Revert "Revert "Remove nulls from sms_sender"" 2017-06-01 11:00:26 +01:00
Leo Hemsted
ea0ba8d87a Revert "Remove nulls from sms_sender" 2017-05-31 14:52:48 +01:00
Rebecca Law
0b642623fb Added table and model for letter rates.
The rates for the letters are per page, therefore it seemed better to build a different table.
2017-05-31 13:34:54 +01:00
Leo Hemsted
eb6edf06a3 add upgrade script to remove non-null values from the sender column 2017-05-30 10:47:15 +01:00
Leo Hemsted
4a85818c34 add inbound sms table 2017-05-30 10:47:01 +01:00
Rebecca Law
3dc70b8c39 Check service.permissions for the existence of schedule_notifications if the notications is being created with a scheduled_for param. 2017-05-26 15:41:14 +01:00
Ken Tsang
f7a18f77cf Update model to cascade permissions assoc proxy 2017-05-25 17:48:09 +01:00
Rebecca Law
b745e13a28 Merge branch 'master' into schedule-api-notification 2017-05-25 13:37:04 +01:00
Leo Hemsted
57b7cb8d24 Merge pull request #986 from alphagov/create-service-bug
separate service deserialization from validation
2017-05-25 10:52:38 +01:00
Leo Hemsted
4b8b6ca91e add test to ensure that updating other things doesnt affect sms sender 2017-05-25 10:37:17 +01:00
Rebecca Law
9f6c037530 Use iso8601 to validate scheduled_for datetime.
Added a validation method that always fails for scheduled notifications.
Comment out config for scheduled task.
The schedule notifications will be turned on once we can invite services to use it.
Waiting for the service permission story, must commit this in order to keep things from going stale.
2017-05-24 16:27:15 +01:00
Leo Hemsted
554a193cff separate service deserialization from validation
Marshmallow validates and deserialises - BUT, when it deserialises,
it explicitly sets `sms_sender=None`, even when you haven't passed
sms_sender in. This is problematic, because we wanted to take advantage
of sqlalchemy's default value to set sms_sender to `GOVUK` when the
actual DB commit happens.

Instead, still use marshmallow for validating, but manually carry out
the json deserialisation in the model class.

This fixes a bug that only manifested when the database was upgraded,
but the code hadn't updated. 🎉
2017-05-24 16:27:12 +01:00
Imdad Ahad
c986b88e21 Merge pull request #979 from alphagov/imdad-migration-add-normalised-to-notification
Add normalised_to field to notification
2017-05-24 16:21:15 +01:00
Rebecca Law
383dee3bb2 Updated the serialization of Notification.scheduled_for to include minutes. 2017-05-24 14:52:32 +01:00
Martyn Inglis
511e143ace toString on the rates object 2017-05-24 08:57:11 +01:00
Leo Hemsted
e9b1fd4dde Revert "Non null sender" 2017-05-23 16:32:03 +01:00
Rebecca Law
53efb4e033 Merge branch 'master' into schedule-api-notification
Conflicts:
	tests/app/v2/notifications/test_post_notifications.py
2017-05-23 13:58:50 +01:00
Martyn Inglis
e987668b0c Merge branch 'master' into remove-nasty-query-from-dashboard 2017-05-23 13:55:30 +01:00
Leo Hemsted
47560515dc add upgrade script to remove non-null values from the sender column 2017-05-23 11:33:43 +01:00
Leo Hemsted
f899d74325 Merge pull request #973 from alphagov/40604-or-govuk
treat 40604 and GOVUK as not having a sender ID
2017-05-23 11:29:33 +01:00
Leo Hemsted
86c9600b04 use config to get default sender rather than hardcoding
this means that on non-prod envs, it reflects that environment.

it needs to be a lamdba, because the column object is created at import
time, when current_app.config won't have been loaded - this means that
when you create a Service object, that lambda executes and grabs the
correct default value
2017-05-23 11:12:37 +01:00
Imdad Ahad
24dfcd2128 Add normalised_to field to notification 2017-05-23 10:44:39 +01:00
Ken Tsang
de7ad6fb95 Refactored service_permissions data model 2017-05-22 17:25:58 +01:00
Leo Hemsted
2535a7fe98 set sms_sender to be 'GOVUK' if not otherwise specified
this is a precursor to making the column non-nullable
2017-05-22 17:13:35 +01:00
kentsanggds
f5d3eed7e0 Revert "Refactored service permissisons data model" 2017-05-22 16:05:31 +01:00
Rebecca Law
9bfba52f53 Add pending flag to scheduled_notifications.
Set pending flag to false when the notification has been sent to provider task.
2017-05-22 15:07:16 +01:00
Rebecca Law
3a3161ecc4 Merge branch 'master' into schedule-api-notification
Conflicts:
	app/celery/scheduled_tasks.py
	app/v2/notifications/post_notifications.py
	tests/app/celery/test_scheduled_tasks.py
2017-05-22 14:05:57 +01:00
Ken Tsang
052004bef0 Refactored data model to remove cascade 2017-05-22 13:33:43 +01:00