Commit Graph

87 Commits

Author SHA1 Message Date
Katie Smith
1b5aaed10a Create DAO for daily sorted letter model 2018-03-06 09:09:02 +00:00
Richard Chapman
a4feaba309 Added tests to tests for precompiled flow and refactored a little
* Added is_precompiled_letter method to letter/utils.py
* Added tests for letter/utils.py
* Added tests for the rest endpoint
* Moved the Precompiled name to a central location
* Added hidden field to the test method to create a template
2018-03-05 14:11:37 +00:00
Rebecca Law
7faf375375 Merge pull request #1695 from alphagov/org-user-endpoints
Organisation user endpoints
2018-02-26 16:27:01 +00:00
Alexey Bezhan
e659253b01 Set Notify service user as the creator of Pre-compiled PDF template 2018-02-23 17:52:24 +00:00
Leo Hemsted
57a174aeb4 add tests for org invite rest, and update conftest 2018-02-23 10:45:18 +00:00
Katie Smith
6a79eedbce Add Organisation DAO 2018-02-08 14:44:40 +00:00
Leo Hemsted
2f79da8702 create, edit and use email branding instead of organisation
notable things that have been kept until migration is complete:

* passing in `organisation` to update_service will update email branding
* both `/email-branding` and `/organisation` hit the same code
* service endpoints still return organisation as well as email branding
2018-02-06 11:23:34 +00:00
Rebecca Law
c54e0d322b A little clean up 2017-12-28 10:58:15 +00:00
Rebecca Law
c5c40a0866 Merge branch 'master' into populate-monthly-letter-usages 2017-12-19 13:28:00 +00:00
Alexey Bezhan
8afe9aced7 Allow setting reply_to when creating a test template 2017-12-19 10:23:24 +00:00
Rebecca Law
012d80003a Update montly billing with letters 2017-12-14 17:17:05 +00:00
Rebecca Law
a836ed037e Added query for billing usage of letter notifications. 2017-12-11 16:55:23 +00:00
venusbb
ad861f2d55 Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-receipt-callback-dao 2017-12-01 14:36:25 +00:00
venusbb
d03280776d CodeStyle correction 2017-11-30 09:38:57 +00:00
venusbb
6a994793dc Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-receipt-callback-dao 2017-11-29 17:39:33 +00:00
Leo Hemsted
4e741bab90 Merge pull request #1441 from alphagov/flake8-tests
Flake8 tests
2017-11-29 16:54:29 +00:00
Rebecca Law
8aa94af5d7 Stop populating the notification to sender mapping table when creating a notificaiton. 2017-11-29 16:47:23 +00:00
venusbb
c07e804319 Created service_callback_api daos 2017-11-29 15:58:11 +00:00
Leo Hemsted
08494ef206 more flake8. lots of unused imports and variables that didn't get used. i tried to preserve old variable names as comments when it looked like they were useful (eg when they were describing timestamps) 2017-11-28 17:23:09 +00:00
Rebecca Law
03c3ebbbe7 Update send_to_providers and create_dvla_file_contents_for_notifications to use notification.reply_to_text.
The next thing to do is to stop updating the notification to sender mapping tables.
2017-11-27 15:24:16 +00:00
Rebecca Law
5450af661e Merge branch 'master' into add-reply-to-notifications 2017-11-27 10:40:02 +00:00
Rebecca Law
049daa0cb8 Save reply_to_text for one off notiications and csv notificaitons. 2017-11-25 11:31:36 +00:00
Chris Hill-Scott
b2ba2afbcd List templates in alphabetical order
Currently templates are ordered by the newest created first. This made
sense when, after creating a new template, you were landed on the page
that listed all the templates. In other words, you needed to see
confirmation of the thing that you’ve just done.

Now (since https://github.com/alphagov/notifications-admin/pull/1195)
you get landed on the page for just that template. So you always see
the template you’ve just created, no matter how the list of templates is
ordered. So we are free to change the order of the templates.

Ordering by time created is not great, because it gives users no control
over which templates appear first. For example, our research reported
this from one team:

> One frustration they have is that when you add a new template it
> automatically goes to the top of the list. To get round this, whenever
> they add a new template they delete all of the existing ones and start
> again because they want to keep their templates in numerical order.
> They'd like to be able to control the order of templates in the list.

We _could_ give people some sort of drag-and-drop template ordering
thing. But this feels like overkill. I think that alphabetical order is
better because:

- it’s easily discoverable – anyone who wants to know how a list is
  ordered can quickly tell just by looking at it
- it’s universal – everyone knows how alphabetical ordering works
- it’s familiar – this is how people documents on their computer are
  ordered; there’s no new UI to learn
- it’s what users are doing already – from the same service as above:
  > They number their templates 1,2a, 2b, 3a etc

So this commit changes the ordering from newest created first to
alphabetical.

Previous changes to template order and navigation:
- https://github.com/alphagov/notifications-admin/pull/1163
- https://github.com/alphagov/notifications-admin/pull/1195
- https://github.com/alphagov/notifications-admin/pull/1330

Implementation notes
---

I refactored some of the tests here. I still don’t think they’re great
tests, but they’re a little more Pythonic now at least.

I also added a sort by template type, so that the order is deterministic
when you have, for example, an email template and a text message
template with the same name. If you have two text message templates with
the same name you’re on your own.
2017-11-23 15:11:07 +00:00
Chris Hill-Scott
e8a94422e5 Make SMS prefix setting non-nullable
We have now:
- defaulted new services to start with this column set to `true`
- migrated all preexisting services[1] to have either `true` or `false` set
  for this column

There is no way for a service to switch back from `true`/`false` to
`null`.

This means that we can safely enforce a non-nullable constraint on this
column now.

1. There is a little gotcha: the GOV.UK Notify service still relies on
   the `sms_sender` column. It doesn’t have a row in the
   `service_sms_senders` table. This means the previous migration
   never changed this service’s value for `prefix_sms` from `null`. So
   this commit also changes its value to `False`, so that the rest of
   the migration, of the whole column, is possible.
2017-11-16 14:29:32 +00:00
Rebecca Law
fd217e67f5 Merge branch 'master' into remove-initial-update-sms-sender 2017-11-15 12:33:38 +00:00
Rebecca Law
fc5dae8ec2 refactored create_service_with_defined_sms_sender 2017-11-15 11:04:33 +00:00
Rebecca Law
45bf7e1938 Fix db migration merge conflict
Update create_service_with_inbound_number
2017-11-15 11:00:56 +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
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
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