Commit Graph

58 Commits

Author SHA1 Message Date
Chris Hill-Scott
ab583c0bc6 Merge pull request #1364 from alphagov/put-sms-prefix-on-model
Work out SMS message prefixing in a way that is aware of multiple SMS senders
2017-11-03 13:35:38 +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
venusbb
6875ab150a Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-free-sms-limit-history 2017-11-02 12:38:52 +00:00
venusbb
6f7793d761 - Add update dao_update_annual_billing_for_current_and_future_years
- moved get_current_financial_year_start_year from service.utils to dao.date_utils
- Moved logic for data persistence from rest to dao when updating records in db
2017-11-02 12:38:43 +00:00
Rebecca Law
0887910b1b Get the sms sender from the notificaiton_sms_sender mapping table if that does not exist get the default sms sender to pass on to the sms provider. 2017-10-30 14:55:44 +00:00
Rebecca Law
6dc41c3b47 New endpoints to add and update multiple SMS sender for a service. 2017-10-19 09:58:23 +01:00
Leo Hemsted
5ad6bc7621 ensure emails are formatted before sending
we allow some invalid to addresses - for example, phone numbers with
spaces or brackets - in the database. This is so that users can match
up their data in a format that they expect (since they passed it in).
When we send SMS, we strip this formatting just before sending - but we
weren't with email. This commit changes that and adds some tests.

It also adds formatting for reply_to addresses. We should never expect
invalid reply_to email addresses in our data, but just in case, lets
validate them here.

Also, bump requirements.txt to capture some more email validation
2017-10-16 17:29:45 +01:00
Richard Chapman
8c5771401a A few code style tweaks to adhere to standard for better maintainable code. 2017-10-06 17:08:06 +01:00
Richard Chapman
b311506f37 Updated send_to_providers.py to use the notification email_reply_to address if there is one present otherwise it uses the service email_reply_to so now users can choose a per notification email_reply_to address. 2017-10-06 16:58:32 +01:00
Rebecca Law
0db39bfac8 Fix the unit tests.
I think there was some imports missed when resolving merge conflicts.
Also I'm not sure why the test_update_letter_notification_to_sent or error passed, I've updated them so they do pass.
2017-10-02 15:29:13 +01:00
Rebecca Law
ba7cd79581 Created a get_default_sms_sender method, which returns the default sms_sender from the service_sms_sender table rather than service.sms_sender.
One step closer to removing services.sms_sender.

fix the unit tests
2017-10-02 10:29:00 +01:00
Leo Hemsted
c97b130540 test dvla callback update tasks 2017-09-26 12:36:42 +01:00
Ken Tsang
366d07dbbe Add ServiceLetterContact data model and script 2017-09-21 16:08:49 +01:00
Katie Smith
72760550bd Add endpoint to get the email reply to addresses for a service
- Changed the dao_get_reply_to_by_service_id method to return a list of
results.
- Added a GET /service/<service_id>/email-reply-to endpoint
2017-09-13 16:58:36 +01:00
Katie Smith
01eef6c7f5 Add service_email_reply_to DAO with an upsert method 2017-09-08 14:56:05 +01:00
Katie Smith
9df498106f Add one_off argument to create_notification test function
One off messages have no API key or job ID. If one_off is set to False,
an API key will automatically be added.
2017-08-30 14:40:10 +01:00
Ken Tsang
fb2623962f Moved create_inbound after dao_create_service
- Need to do this otherwise no service.id is available to link the servce to the inbound number
2017-08-23 14:03:41 +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
Imdad Ahad
63e1167098 Make sure we update the correct month for billing:
When populating the monthly billing records on a schedule, we need
to ensure the correct month is being updated.

As an example, if the current datetime is 31 Mar 2016, 23:00. The
BST equivalent is the 1st April. Therefore we need to ensure we
update billing for April, not March. This takes care of that.
2017-08-11 16:57:17 +01:00
Ken Tsang
668811197c Remove whitespace 2017-08-11 12:56:59 +01:00
Ken Tsang
5e2d0bf5c6 Update test fixture to provide default provider 2017-08-11 12:56:59 +01:00
Ken Tsang
4de6060694 Add data models, dao for inbound_numbers 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
5d61b3644c add tests for new test-key handling 2017-08-02 11:14:05 +01:00
Leo Hemsted
075d2a3346 tighten key_type validation on letters api
when in research mode or test key, dont send letters via api - instead,
just put them straight to success state

when using a team key, flat out reject the request (403)
2017-08-01 15:49:00 +01:00
Rebecca Law
eaf5cbb868 Add labels to query so that the named tuples can be referenced later.
Remove unnecessary function
2017-07-25 11:43:41 +01:00
Rebecca Law
9400988d72 Monthly billing - part 1
This is still a work in progress but it would be good to get some eyes on it.
This commit includes creating and updating a row in the monthly billing table and a method to fetch the results.
There is a command to populate the monthly billing for a service and month so we can try it out.
The total cost at the moment are wrong, they do not take into account the free allowance - see notes below about adding that to the table.
Left to do:
create a nightly task to run to update the monthly totals.
create an endpoint to return the yearly billing, the current day will need to be calculated on the fly and added to the totals.
Add the free allowance into the total costs.
2017-07-18 18:21:35 +01:00
Ken Tsang
37df051c32 Updated Organisations DAO 2017-07-12 12:01:50 +01:00
Ken Tsang
c743e52fe8 Add organisations model and create dao 2017-07-12 12:01:50 +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
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
Martyn Inglis
21a5f01804 Not null in own PR 2017-06-05 13:10:54 +01:00
Imdad Ahad
0631b6c988 Add dao to delete inbound sms after seven days 2017-06-02 16:10:27 +01:00
Leo Hemsted
bf18b179b0 ensure the user_number in inbound sms is international
rather than using the `normalise_phone_number` function, use the
`validate_and_format_phone_number` function - this will also convert
all numbers to international format, which means we won't need to
worry about whether the user enters internaional or UK phone numbers
when searching
2017-06-02 15:20:18 +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
Leo Hemsted
4a85818c34 add inbound sms table 2017-05-30 10:47:01 +01:00
Imdad Ahad
78c10b7d30 Search notification against normalised recipient with filter for status 2017-05-26 11:45:56 +01:00
Rebecca Law
f555c7a73b Refactor tests to use the create_notication in tests.app.db 2017-05-25 11:41:07 +01:00
Ken Tsang
e68c3900e8 Add restricted argument for service mock 2017-05-17 16:06:35 +01:00
Ken Tsang
54446d5f4d Add default permissions when creating a service 2017-05-17 14:18:12 +01:00
kentsanggds
c4964d8cf4 Merge pull request #956 from alphagov/add-service-permissions
Add service permissions DAO and refactor user service permission mock
2017-05-16 14:26:15 +01:00
Ken Tsang
733c16b2bb Update to strip down DAO and clarify tests 2017-05-16 12:33:27 +01:00
Ken Tsang
54d801979c Refactored to handle single service permission 2017-05-16 10:57:57 +01:00
Ken Tsang
114d4d84d4 Add service permissions DAO and refactor user service permission mock 2017-05-15 17:28:14 +01:00
Imdad Ahad
5eb02a45a5 Send go live email when service goes live 2017-05-12 14:07:06 +01:00
Imdad Ahad
048861b968 Add dao to get active users for service 2017-05-11 15:39:15 +01:00
Rebecca Law
1a64509186 Change the resultset from the yearly and monthly billing data queries.
Fix some formatting of the return objects.
2017-04-28 10:10:49 +01:00
Martyn Inglis
cdd3ad687c updated the fixture 2017-04-27 12:14:31 +01:00
Leo Hemsted
935e566284 add tests for letters not getting excluded 2017-04-19 14:22:25 +01:00
Ken Tsang
06ec7a59a6 Refactored code to personalise subject 2017-04-11 16:19:43 +01:00