Commit Graph

114 Commits

Author SHA1 Message Date
Katie Smith
6727f0e0f5 Update ft_billing DAO functions to use postage
* Updated the 'fetch_billing_data_for_day' DAO function to take postage into
account
* Updated the 'update_fact_billing' DAO function to insert postage for
new rows. When updating rows which are identical apart from the postage, the
original row will be kept. (This behaviour will change once postage is
added to the primary key - at this point, upserting will add a new row.)
* Also changed some fixtures / test set up functions to take postage
into account
2018-09-28 13:52:17 +01:00
Leo Hemsted
918e4b390f add postage to notification + noti_history
if it's a letter notification, postage must equal "first" or "second",
else it must equal null
2018-09-19 16:32:58 +01:00
Rebecca Law
1c0892888f Change the name of letter_class to postage, this will match the domain language used in the documentation.
Updated the tests to answer review comments.
2018-09-18 15:22:08 +01:00
Rebecca Law
efb618e956 Fix merge conflicts for the db migration file.
Update test_services_dao to stop using fixtures. This is a massive change. The only real change in the file is to check for the letter_class.
2018-09-17 15:45:29 +01:00
Chris Hill-Scott
337496c5bc Deprecate service branding column
We want to drop this column. First we have to stop using it anywhere.

Needs to be made nullable so we can stop writing to it.
2018-08-30 16:05:37 +01:00
Rebecca Law
fd16d7060a Added a method to decide which colour to send to the notifications-utils HTMLEmailTemplate to create the content. 2018-08-22 12:59:06 +01:00
Pea Tyczynska
d8d94b431f Find email_branding by name 2018-07-31 17:58:19 +01:00
Pea Tyczynska
ca2b350a99 Remove references to monthly_billing table from api 2018-07-30 11:07:42 +01:00
Katie Smith
b1cfa8942a Add one_off filter when getting all notifications for a service
Added the option to filter by one_off messages to the DAO function
`get_notifications_for_service`. Previously, one-off notifications
were not returned - this has changed so that the default is for
one-off notifications to be returned. Also simplified the `include_jobs`
filter for this function.

The DAO function gets used in 3 places - for the V1 and V2 API endpoints,
which will now start to return one-off messages. It also gets used by
the admin app which needs to pass in `include_one_off=False` to the
`get_all_notifications_for_service` where we don't want one-off
notifications to show, such as the API message log page.
2018-07-18 15:08:06 +01:00
Pea Tyczynska
86978c225a Filter 'get_service_callback_api_for_service' to only get status updates
Also rename it to 'get_service_delivery_status_callback_api_for_service'
2018-07-18 11:36:39 +01:00
Rebecca Law
e2a1dfeb31 New dao and endpoints to create and update service data retention. 2018-07-11 17:02:49 +01:00
Katie Smith
c57f33a02d Use real letter_rates in tests
Added the letter_rate table to the list of tables which does not get
deleted after each test run and changed the tests to use the real letter
rates.

Also removed the letter rate DAO since this was only being used in
tests, so was no longer needed.
2018-07-10 11:31:18 +01:00
Leo Hemsted
be52adc68f add tests for monthly notification stats 2018-07-03 14:58:32 +01:00
Leo Hemsted
089056ef72 add tests for new statistics and fact notification status functions 2018-07-03 14:58:32 +01:00
Rebecca Law
28beeebbf4 Added a query and endpoint to return the count of complaints for a date-range.
Unit tests for complaints_rest.get_complaint_count have yet to be written.
Maybe there is a better name for the new endpoint.
2018-06-27 09:11:38 +01:00
Rebecca Law
4966da8289 Fix to handle_complaints.
The json we were getting from SES was not quite as expected, the test data now reflects what we get.
New test added, fix a test that was passing regardless.
2018-06-06 10:37:31 +01:00
Rebecca Law
c5524a3fe9 [WIP] 2018-06-05 17:23:24 +01:00
Rebecca Law
64f077f2f4 New endpoint to return data for complaints. 2018-06-05 14:25:24 +01:00
Rebecca Law
7fa42c2cc5 When SES callback is for a complaint save that to the new complaints table.
When handling the complaint we don't want to throw an exception if the message is missing fields. Only log an exception if we are unable to tie a complaint to a notification.
2018-06-04 17:29:58 +01:00
Katie Smith
663021e494 Only return active SMS senders
Updated the DAO methods which return a single SMS sender and all SMS senders
to only return the non-archived senders. Changed the error raised in the Admin
interface from a SQLAlchemyError to a BadRequestError.
2018-04-30 15:25:17 +01:00
Katie Smith
f810daa3c5 Only return non-archived letter contact blocks
Changed DAO functions which return one letter contact block and all
letter contact blocks for a service to only return non-archived ones.
2018-04-30 15:25:17 +01:00
Katie Smith
a57b2f50c2 Only return non-archived email reply_to addresses
Updated the DAO methods which return a single email reply_to address and
all reply_to addresses to only return the non-archived addresses.

Changed the type of error that gets raised when using the Admin
interface to be BadRequestError instead of a SQLAlchemyError.
2018-04-30 15:25:17 +01:00
Rebecca Law
16ef133aa5 Refactor reporting task so that methods can be used for the annual usage page.
Still a work in progress, tests are coming.
2018-04-25 14:45:51 +01:00
Rebecca Law
8cd4e1be29 Query ft_billing aggregate for a month 2018-04-25 14:45:51 +01:00
Rebecca Law
82cc6d6bef As it turns out the s3ftp used to mount the s3 bucket to our ftp server puts the file on s3 more than once. So the SNS topic is triggered more than once.
We need to deal with this, it's ok when updating a notification status from delivered to delivered. But the DailySortedLetter counts are being doubled.
Adding the file_name to the table as a unique key to get around this issue. It will mean we have multiple rows for each billing_day, but that's ok we can aggregate that.
This will also give us a way to see which file created which count.
2018-03-14 17:04:58 +00:00
kentsanggds
b0b0062b35 Merge pull request #1732 from alphagov/ken-hidden-in-json-response
Return `is_precompiled_letter` field as part of json for notification by id
2018-03-08 15:06:10 +00:00
Ken Tsang
ee9b6f1fe0 Return hidden field as part of json for notification by id
- required by Admin app so that it can distinguish between created and precompiled letters
2018-03-06 12:46:06 +00:00
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