Commit Graph

233 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
c62f2a3f7c Update create_custom_template test helper to create history object
`create_custom_template` is not using `dao_create_template` since
it explicitly sets a template id. Notifications.template relationship
now refers to a TemplateHistory objects, so we need to make sure that
`create_custom_template` creates a matching TemplateHistory record
when it creates a Template.
2017-11-10 15:13:55 +00:00
Alexey Bezhan
94dae42902 Avoid assigning notification.template when creating test objects
`Notification.template` changed from being a Template relationship
to TemplateHistory. When a relationship attribute is being assigned,
SQLAlchemy checks that the assigned value type matches the relationship
type. Since most tests at the moment create a notification using a
Template instance this check fails.

Rewriting the tests to use TemplateHistory objects would require
changes to the majority of tests. Instead, when creating a notification
objects we assign the foreign key attributes directly. This skips the
SQLAlchemy type check, but we still get the constraint check on the
foreign keys, so a matching TemplateHistory object needs to exist in
the database.
2017-11-10 15:12:07 +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
6af616eb83 add name to personalisation and urlencode next param
also add tests
2017-11-07 16:47:26 +00:00
Leo Hemsted
dd326ec1d3 add new template to config
and rename existing new user email verification template for clarity
2017-11-07 16:47:26 +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
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
Chris Hill-Scott
46d45d8595 Make international SMS on for new services
International SMS is a mature, documented feature now. There’s no reason
it shouldn’t be available to everyone. If it’s turned off by default
then we’re relying on people finding it in the settings page to know
that it exists (which we found in research the other week that users,
who would have benefitted from having international SMS, were failing to
do).

This also fixes the problem whereby users signing up for Notify with an
international phone number (eg those working abroad for the Foreign and
Commonwealth Office) couldn’t get through the tour because they weren’t
able to send themselves the example text message (see
https://www.pivotaltracker.com/story/show/150705515).
2017-10-19 11:43:27 +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
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
Imdad Ahad
cb37ba5f78 Update schema to return default letter contact for a service 2017-10-03 10:31:21 +01:00
Chris Hill-Scott
fa8e4b29f2 Return placeholders when getting a template
> Currently when retrieving a template via one of the clients, we do
> not return the personalisation fields that are required for that
> template.
>
> This is useful for services who want to perform template validation on
> their own systems. A service user has also requested this.

– https://www.pivotaltracker.com/story/show/150674476

This commit adds an extra attribute to the JSON response containing an
array of the placeholder names. This key is called "personalisation",
to match the argument that developers use to pass in the values of
placeholders.
2017-09-22 10:00:23 +01:00
Leo Hemsted
e18e78180e update letter tests to use correct service
previously they were using sample_service fixture under the hood, but
with full permissions added - this works fine, **unless** there's
already a service with the name "sample service" in the database. This
can happen for two reasons:

* A previous test didn't tear down correctly
* This test already invoked the sample_service fixture somehow

If this happens, we just return the existing service, without modifying
its values - values that we might change in tests, such as
research mode or letters permissions.

In the future, we'll have to be vigilant! and aware! and careful! to
not use sample_service if we're doing tests involving letters, since
they create a service with a different name now
2017-09-21 11:50:49 +01:00
Chris Hill-Scott
29a962060f Return delivery estimate for letter notifications
> For get all or get one letter the response needs to be updated so that
> it looks similar to admin app.
>
> status: created|sending --> received letter
> new column: `estimated delivery date`: derived from created at date.
> (see how the admin app is doing it)
>
> NOTE:
> At the moment we only have 2 statuses for a letter created and
> sending, but we will want to have other internal statuses that make
> sense to the Notify team but not our services. When we know those
> statuses the status map will be updated at that point.

– https://www.pivotaltracker.com/story/show/150512525

This commit implements the date (not status) part of this story.
2017-09-15 14:58:07 +01:00
Rebecca Law
e32abb0ada Merge pull request #1221 from alphagov/ken-no-letters-when-trial
Stop letters when service is in trial
2017-09-05 15:33:50 +01:00
Imdad Ahad
72de309b26 Make perf platform processing stats query the NotificationHistory table 2017-08-31 12:52:59 +01:00
Ken Tsang
7e70b44113 Error in task when letter template and in trial mode 2017-08-30 16:04:10 +01:00
Ken Tsang
fbe1a14304 Removed create_inbound_numberfrom fixture 2017-08-16 14:23:32 +01:00
Ken Tsang
c36423aac6 Refactor code for dao_fetch_servies_by_sms_sender to use inbound_numbers
This will need to be refactored after the deployment of api and admin and after the update script for existing services using inbound numbers has been executed.
2017-08-16 12:51:31 +01:00
Ken Tsang
104fc93503 Refactor code 2017-08-16 12:50:44 +01:00
Ken Tsang
d5b91f9911 Fixed admin_request bug 2017-08-16 12:50:44 +01:00
Ken Tsang
468048797a Refactor conftest 2017-08-16 12:50:44 +01:00
Ken Tsang
e80bc9deb2 Refactor conftest 2017-08-11 12:56:59 +01:00
Ken Tsang
c9f871c0c9 Refatored tests and fixtures for inbound_number 2017-08-11 12:56:59 +01:00
Ken Tsang
3c392596a3 Add backref in InboundNumber model 2017-08-11 12:56:59 +01:00
Leo Hemsted
372b10f19c fix up tests to be internally consistent
notifications should always have at least one of job and api key, and
the key type should match the api key's key type (or be 'normal')
2017-08-02 15:35:56 +01:00
Leo Hemsted
11458c421b ensure permissions are correct in sample letter fixtures
sample_letter_* should always include a service that has letter
permissions.

Also, print out the JSON response in the admin_request fixture if the
response code doesn't match
2017-07-27 11:12:09 +01:00
Ken Tsang
5a82fe0a70 Add inbound sms permission check 2017-07-06 12:31:01 +01:00
Ken Tsang
e927723726 Update sms/email permission tests error msg 2017-07-06 12:27:57 +01:00
Ken Tsang
c1caa4a5da Add tests for when email / sms disabled 2017-07-06 12:27:56 +01:00
Ken Tsang
98cd838510 ken-use-only-new-service-permissions 2017-07-06 12:27:55 +01:00
Leo Hemsted
88a479a4bb make client request fixture args conform 2017-06-20 12:06:49 +01:00
Imdad Ahad
1dacc6c3a3 Updates:
* Skip the decorated tests as that doesn't work as we expect
* Remove magic numbers in tests
2017-06-13 15:22:31 +01:00
Imdad Ahad
6b4597149f Add filter to get jobs to delete (sms, email, letter) 2017-06-06 16:01:27 +01:00
Leo Hemsted
d89cb2c120 add an admin_request fixture
this gets rid of some boilerplate around mocking requests
from the front-end
2017-06-02 15:19:24 +01:00
kentsanggds
263adac805 Merge pull request #984 from alphagov/ken-update-api-service-permissions-handling
Ken update api service permissions handling
2017-05-26 14:39:27 +01:00
Imdad Ahad
77b82305f4 Search normalised in get_notifications_for_service:
* Use dao method to search against normalised(recipient)
* Add filter to accept one or more statuses
2017-05-26 11:58:50 +01:00
Ken Tsang
234312ece0 Update service permissions to ensure state in sync 2017-05-25 17:48:09 +01:00
Rebecca Law
383dee3bb2 Updated the serialization of Notification.scheduled_for to include minutes. 2017-05-24 14:52:32 +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
Rebecca Law
973cc2c4c9 Changed the scheduled_for datetime to only send and hour of a day to send.
Also expect the date being passed in is BST. The date is converted to UTC before saving. And converted to BST when returning a notification.
2017-05-17 15:06:15 +01:00
Ken Tsang
733c16b2bb Update to strip down DAO and clarify tests 2017-05-16 12:33:27 +01:00
Ken Tsang
114d4d84d4 Add service permissions DAO and refactor user service permission mock 2017-05-15 17:28:14 +01:00
Rebecca Law
f0e2713bef Add scheduled_for in the post notification request form.
Return scheduled for in get_notification requests.
2017-05-15 17:27:38 +01:00
Rebecca Law
3b41478a0a Updated Notification model to use Float(asdecimal=False) for rate_mutliplier.
Added test with multiple rows for a month.
2017-04-28 10:10:49 +01:00
Martyn Inglis
2a0f8c8808 Validate International phone numbers
- uses new utils methods to validate phone numbers
- defaults to International=True on validation. This ensures the validator works on all numbers
- Then check if the user can send this message to the number internationally if needed.
2017-04-26 15:56:45 +01:00