Commit Graph

543 Commits

Author SHA1 Message Date
Alexey Bezhan
db1c647873 Remove NotificationHistory.template relationship
Relationship attribute is not used by the application code, so we
can remove it without replacing it with a TemplateHistory one.

This also updates the foreign key constraint to refer to the composite
primary key for the TemplateHistory records.
2017-11-10 15:13:55 +00:00
Alexey Bezhan
bdcc89b403 Add TemplateHistory.redact_personalisation attribute
TemplateHistory objects need to be connected to the template's
TemplateRedacted record. This requires setting up a new SQLAlchemy
relationship to allow accessing redact_personalisation from
TemplateHistory instances.

We can avoid creating a foreign key in this case by setting up an
explicit `primaryjoin` expression. Since TemplateHistory.id is
created from Template.id and TemplateRedacted.template_id is
already a foreign key to Template.id the foreign key should always
be valid even without a DB constraint.
2017-11-10 15:13:55 +00:00
Alexey Bezhan
79d417f13b Add TemplateHistory.get_link method
Notifications.serialize calls `Notifications.template.get_link`, so
we need TemplateHistory objects to generate their API URLs.

This generates a link to the `/v2/` version of the endpoint.
2017-11-10 15:13:55 +00:00
Alexey Bezhan
52e0367a13 Replace Notifications.template_history with Notifications.template
Each notification instance is connected to a specific version of the
template that was used to generate notification content. Template
versions are stored in TemplateHistory, so that's the table we need
to use for Notifications.template relationship.

Currently, using Notifications.template returns the latest template
version, which leads to incorrect content being returned by the API
if the template has been updated.

This change removes Notifications.template_history attribute and
replaces template relationship to refer to TemplateHistory instance
based on the notification's template ID and version.
2017-11-10 15:12:07 +00:00
Leo Hemsted
6332058781 remove PUT /user/<id> 2017-11-10 10:49:44 +00:00
kentsanggds
34aa8dfd01 Merge pull request #1373 from alphagov/ken-get-inbound_sms-api
Get inbound SMS API
2017-11-10 10:25:02 +00:00
Leo Hemsted
15bf888624 make user mobile num nullable if user has email_auth enabled 2017-11-09 19:07:44 +00:00
Ken Tsang
cd4637a1d7 Removed provider_reference and provider_date from serialize 2017-11-09 15:22:27 +00:00
Rebecca Law
d3fcba621b Remove sms_sender from Service model.
Remove unused dao method.
2017-11-09 14:01:02 +00:00
Rebecca Law
3713cc2353 Merge branch 'master' into remove-initial-update-sms-sender 2017-11-09 11:53:29 +00:00
Richard Chapman
8973e42b86 Added a new table ‘stats_template_usage_by_month’
Currently the 'See templates used by month' report is timing out for
some services due to the query time of the data from notification_history
This is a stats table which will hold the data and will be updated by a
scheduled celery task once a day. This data will be combined with the
'live' data from notifications tables (which will be considerably less)
to form the data of the new report.
2017-11-09 10:34:49 +00:00
Rebecca Law
0054361044 Refactor the sms sender code to remove any unused methods.
Refactor tests/db/create_service() to behave more like the real world.
Created new create_service_with_inbound_number and create_service_with_defined_sms_sender() test/db methods.
2017-11-07 14:26:18 +00:00
Ken Tsang
85b8e24e17 Add V2 inbound_sms API
- had to update the serialization in the model so that the date time is appended with the UTC timezone
- test has been added to ensure that the schema will validate the response correctly
2017-11-07 13:29:40 +00:00
Chris Hill-Scott
812090b104 Default new services to prefixing text messages
We want new services, when they do the tour, to see how the service name
they just made shows up in the messages. This is how it (should) work
at the moment (although got broken because of the multiple senders
stuff).

Need to do this before we do the migration now otherwise a new service
could sneak in with this setting still set to `null`.
2017-11-03 15:52:56 +00:00
Chris Hill-Scott
cccffdd2ac Add a column for a service to set SMS prefixing
In future changes, services will be able to control whether their text
messages will be prefixed with the name of their service.

This commit:
- adds a column to store the value of that setting
- makes the service model take notice of it, if it were to have a value
  set

It doesn’t:
- provide a way of setting the value of this column

Currently the column can have three values:
- `None` – ignore it (this is what all current services will start as)
  and continue to determine whether to prefix messages by looking at the
  sender
- `True` – always the service name to the start of text messages
- `False` – never add the service name to the start of text messages

In the future we’ll migrate all services to be either `True` or `False`,
the `None` will go away and all services will have direct control over
the setting.
2017-11-03 12:53:06 +00:00
Chris Hill-Scott
92b605833f Add prefix SMS with service name to service model
If the service is sending messages from GOVUK, then its messages should
be prefixed with the service name. Right now this logic is:
- worked out separately in the admin app and API
- isn’t aware of multiple senders

This commit moves the logic to one place (the service model). It does
this in a slightly naive way, in that it only looks at the default
sender, not the actual sender of the message.

In the future this will go away because we’ll move it to being a setting
that’s controlled independently of the service name. But this is the
first step towards that.

fixup! Add prefix SMS with service name to service model
2017-11-03 12:28:35 +00:00
Rebecca Law
f5e79302cd Remove NotificationStatistics
NotificationStatistics was added as a spike but didn't work out as expected. This is finally removing all that unused code.
I'll drop the table in the next PR
2017-11-01 15:02:50 +00:00
Leo Hemsted
c39ec90727 add auth type table, currently contains sms_auth and email_auth 2017-10-30 11:11:37 +00:00
venusbb
b648c2e632 Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-free-sms-limit-history 2017-10-30 09:34:23 +00:00
Leo Hemsted
46f5896b3b add new email_auth service permission 2017-10-27 14:28:20 +01:00
venusbb
6f02ee516c Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-free-sms-limit-history 2017-10-27 10:47:20 +01:00
Rebecca Law
4f65ca5447 Create a new table to map a notification to a SMS sender.
There is also some minor db model updates here so that the python db model match the db
2017-10-26 15:25:38 +01:00
venusbb
c10cde6b22 modified serialized method and schema 2017-10-26 13:25:11 +01:00
venusbb
e88b311c8e Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-free-sms-limit-history 2017-10-26 11:56:14 +01:00
kentsanggds
d39bf96324 Merge pull request #1333 from alphagov/ken-handle-dvla-response-file
Handle DVLA response file
2017-10-26 11:09:09 +01:00
Ken Tsang
b40cab0c5d Refactored models to make const consistent 2017-10-25 15:38:58 +01:00
venusbb
8ad98f2806 create entry when creating a new service 2017-10-25 11:35:13 +01:00
Ken Tsang
a2b42194cd Add letter status received to data model
- in order to reduce the number of statuses in the database the letter status `received` will be mapped to `delivered` internally
2017-10-25 10:48:35 +01:00
venusbb
b9b0814853 Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-free-sms-limit-history 2017-10-24 14:44:32 +01:00
Rebecca Law
8d6c38e1fe Now that we allow multiple SMS senders for a service, update the sender for SMS to be the default SMS sender, regardless if it is inbound number or not 2017-10-24 13:37:17 +01:00
venusbb
59dd343254 Added free_sms_fragment_limit model, schema, dao and Rest 2017-10-24 13:23:24 +01:00
Rebecca Law
954a80649e Merge branch 'master' into add-update-multiple-sms-sender 2017-10-19 14:34:58 +01:00
venusbb
b0872d9466 add unique service_id&year constraint 2017-10-19 14:21:10 +01:00
venusbb
7e78e19500 Unique constrain and db.relationship 2017-10-19 12:00:01 +01:00
Rebecca Law
709e24e267 Added endpoints to get sms senders for a service 2017-10-19 10:43:49 +01:00
Rebecca Law
6dc41c3b47 New endpoints to add and update multiple SMS sender for a service. 2017-10-19 09:58:23 +01:00
venusbb
b2fa7cdd83 create new table annual_billing 2017-10-18 15:35:51 +01:00
Rebecca Law
1a463cba1f Merge branch 'master' into add-update-multiple-sms-sender 2017-10-18 11:18:44 +01:00
Chris Hill-Scott
2a5e6c2d0c Store organisation type against each service
> So that we can default services to their appropriate text allowance,
> we need to find out what sector they're in. So let's start collecting
> that from teams as they create new services.

In order to work out what a team’s allowance should be, we need to know
what part of government they’re from. We’re going to do this logic in
the admin app and then `POST` the allowance to the API.

So all we need to do with the information that the users give us is
store it against the service, so we have a record. Doesn’t need any
logic doing as a result of it, doesn’t need foreign keying to the
organisations table, etc.
2017-10-18 10:49:31 +01:00
Rebecca Law
809c5fc055 Remove unique constraint for ServiceSmsSenders.
This will allow a service to have multiple sms senders.
2017-10-17 16:49:50 +01:00
Venus Bailey
9b60d69931 Revert "Revert "[#151837054] Add new column free_sms_fragment_limit in the Services table"" 2017-10-16 16:24:34 +01:00
Venus Bailey
616a6f8ef8 Revert "[#151837054] Add new column free_sms_fragment_limit in the Services table" 2017-10-16 12:43:05 +01:00
venusbb
f95282a84d Add column, free_sms_fragment_limit, to services & services_history
- Created new column in both tables
- Modified model and Service schema
- Modifed existing test
2017-10-12 12:16:13 +01:00
Rebecca Law
9d507466ef Remove exception thrown when getting default sender.
Having more than one default is checked on insert and update.
2017-10-04 14:51:02 +01:00
Rebecca Law
78a9d74c49 Merge branch 'master' into return-service_sms_sender_value 2017-10-04 13:29:05 +01:00
Katie Smith
0903a28ba8 Merge pull request #1281 from alphagov/imdad-katie-return-letter-contact-from-new-table
[4/4] Use letter contact from the new table
2017-10-03 16:42:40 +01:00
Katie Smith
dede336b3b Update tests to not use letter contact block from services table
A few test updates were needed after rebasing onto master.
2017-10-03 13:35:09 +01:00
Richard Chapman
e4b95ab20a Merge pull request #1282 from alphagov/rc_notifications_email_sender
[1/10] Allow API calls to specify the reply address option
2017-10-03 11:56:26 +01:00
Richard Chapman
d8e1a34610 Added a unique constraint to the notification_id column of the notification_to_email_reply_to table so that each notification can only have one mapping to service_email_reply_to and hence one email address. 2017-10-03 11:03:31 +01:00
Imdad Ahad
4eebd9a83c Remove the letter_contact_block from the Service model 2017-10-03 10:31:21 +01:00