Commit Graph

100 Commits

Author SHA1 Message Date
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
3602431c2a Renamed test and refactored fixtures 2017-05-16 13:41:54 +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
d993e1a43e Don't send notification if other service attrs changed 2017-05-15 15:02:01 +01:00
Imdad Ahad
5eb02a45a5 Send go live email when service goes live 2017-05-12 14:07:06 +01:00
Leo Hemsted
348183d93b Merge pull request #942 from alphagov/status-as-table
notification status as table
2017-05-10 13:54:49 +01:00
Rebecca Law
a564b9aeb0 Update /service/{}/notifications to look for a "to" query string, if it exists call the search notifications_by_to_field method. 2017-05-08 17:20:21 +01:00
Rebecca Law
d252dc8976 New endpoint to search by "to" field of the notification.
The query ignores case and spaces.
2017-05-05 14:12:50 +01:00
Leo Hemsted
7e52fa4d13 add new notification_status column to models.py
We now have a new column in the database, but it isn't being
populated. The first step is to make sure we update this column,
while still keeping the old enum based column up to date as well.

A couple of changes have had to happen to support this - one irritating
thing is that if we're ever querying columns individually, including
`Notification.status`, then we'll need to give that column a label,
since under the hood it translates to `Notification._status_enum`.
Accessing status through the ORM (i.e., my_noti.status = 'sending' or
similar) will work fine.
2017-05-04 17:24:28 +01:00
Ken Tsang
03885fea2f Update tests with new rates 2017-05-03 13:13:13 +01:00
Ken Tsang
baf84b53d3 Update test to check it doesn't get email usage 2017-04-28 10:10:49 +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
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
Rebecca Law
a186fc95be Added new endpoints to return the yearly-usage and monthly-usage for a given financial year and service id.
Since the response has changed I have created new endpoints so that the deployments for Admin are more managable.

Removed print statements from some tests.
2017-04-28 10:10:48 +01:00
Ken Tsang
aed9bc0fe7 Added tests for international sms flag 2017-04-24 13:01:13 +01:00
Imdad Ahad
c4fac1d937 Revert "Revert "add DVLA organisations to API"" 2017-04-21 16:05:07 +01:00
Leo Hemsted
c3e56d5d2d Revert "add DVLA organisations to API" 2017-04-20 18:21:56 +01:00
Leo Hemsted
76676280ab add create service tests for dvla_org 2017-04-20 17:22:45 +01:00
Leo Hemsted
d514d99a67 add DVLA organisations to API
when services are created, they'll have a dvla_org_id of 001, or
HM Government. That can be changed later using a regular update call
2017-04-19 16:31:18 +01:00
Ken Tsang
5f945ab30e Refactored code, changed now to utcnow in test 2017-03-29 11:47:41 +01:00
Ken Tsang
af78efd137 Fix get_detailed_services BST 2017-03-29 11:03:28 +01:00
Leo Hemsted
d639aa22df skip failing timezone test
TODO fixme
2017-03-28 14:02:47 +01:00
Rebecca Law
f880604c85 First attempt at securing the endpoints.
Started with adding a before_request event to the service_blueprint, which executes the requires_admin_auth method rather than the require_auth method.

Obviously this is not done but want to get this in front of people to get an opinion.
2017-03-16 10:42:45 +00:00
Imdad Ahad
36d52c6e42 Add template type to response and refactor 2017-03-08 12:01:38 +00:00
Imdad Ahad
520c588d56 Add endpoint to retreive stats for service by template per month 2017-03-08 12:01:38 +00:00
Chris Hill-Scott
cffd0c2c54 Remove weekly stats endpoints
The weekly stats endpoint wont be used once
https://github.com/alphagov/notifications-admin/pull/1109 has been
merged.

It has been replaced with a new monthly endpoint in
https://github.com/alphagov/notifications-api/pull/807
2017-02-08 13:16:41 +00:00
Leo Hemsted
855a412c90 Merge pull request #812 from alphagov/plat-adm-dates
make sure we convert strings to dates before we use them
2017-01-31 16:24:30 +00:00
Leo Hemsted
cd47dbd36b make sure we convert strings to dates before we use them
fixes 500 on platform admin page
2017-01-31 16:12:46 +00:00
Chris Hill-Scott
56ba653f48 Add endpoint for breakdown of activity by month
This endpoint will eventualy replace the weekly breakdown one. By month
for a given financial year is better, because it gives us consistency
with the breakdown of financial usage (and eventually consistency with
the template usage).

The code to do this is a bit convoluted, in order to fill out the counts
for months and statuses where we don’t have notifications.

This will make the admin side of this easier, because we can rely on
there always being numbers available. The admin side will deal with
summing the statuses (eg `temporary-failure` > `failed`) because this
is presentational.

This commit also modifies the usage count to use `.between()` for
consistency.
2017-01-31 14:16:34 +00:00
Leo Hemsted
0d089a383e fix tests in service/test_rest.py 2017-01-31 12:06:25 +00:00
Chris Hill-Scott
4e60265c58 Add tests for billable unit rest endpoint
Doesn’t do extensive tests through the DAO layer, we have separate tests
elsewhere for that. This just tests the query parameter validation.
2017-01-27 11:47:40 +00:00
Leo Hemsted
d550893377 update tests to use create_user instead of sample_user
note that all of these tests have to be checked to ensure that they
still call through to notify_db_session (notify_db not required) to
tear down the database after the test runs - since it's no longer
required to pass it in to the function just to invoke the sample_user
function
2017-01-10 15:04:28 +00:00
Rebecca Law
0ec84ff5e8 Refactor the get_detailed_services so that the start and end date are not defaulted to None.
Set the start and end date to today's date if they are not set in the request.args
2016-12-29 13:50:41 +00:00
Rebecca Law
8ad078b663 Added a date range filter for the get all services end point.
When the start_date and end_date query argruments exists in the request,
the query will return the results from the NotificationHistory table for the given date range.
We will need to check the performance of this query, but this will only be used by the platform admin page.
2016-12-28 15:39:55 +00:00
Jenny Duckett
d2649aebc8 Add include_from_test_key parameter to /service
We want to be able to toggle the numbers on the platform admin page between
including and excluding notifications sent using test keys, so that we can see
both real use of the platform and all load on it.

This parameter defaults to True, which is the existing behaviour.
2016-12-05 17:50:52 +00:00
Leo Hemsted
b0e240267a add only_active flag to get services functionality 2016-11-09 15:07:23 +00:00
Leo Hemsted
d4a300ec7a add only_active flag to GET /services/
does what it says on the tin
2016-11-09 11:45:39 +00:00
Leo Hemsted
3cbacecf19 fix non-functional/overengineered existing tests 2016-11-09 11:32:07 +00:00
Leo Hemsted
da2fa5b4bc move sqlalchemy defaults from booleans to SQL constructs
booleans aren't actually allowed, and quietly do nothing

also default Services.active to true
2016-11-08 17:10:28 +00:00
Leo Hemsted
a45c62d41d add can_send_letters flag to services
defaults to false
2016-10-26 13:01:40 +01:00
Chris Hill-Scott
def1d253aa Add endpoint to get billable units/financial year
`/services/ef7a665d-11a4-425a-a180-a67ca00b69d7/billable-units?year=2016`

Pretty much just passes through to the DAO layer. Validates that year
is:

- present (there’s no need for unbounded queries on this endpoint)
- an integer
2016-10-03 15:50:55 +01:00
Chris Hill-Scott
21f3448fbc Use client fixture 2016-09-23 10:41:37 +01:00
Chris Hill-Scott
ba71079f22 Reduce indentation 2016-09-23 10:41:37 +01:00
Chris Hill-Scott
d7bb83fadf Optionally get notifications created w/ test key
This is only for the method that the admin app uses; it doesn’t affect
the public get notifications endpoint.
2016-09-23 10:40:33 +01:00
Chris Hill-Scott
4217bd2108 Optionally get only notifications created by API
This commit adds the `include_jobs` filter to the
`GET /services/…/notifications` endpoint. It defaults to `True` (ie show
all notifications) but makes it possible to only return notifications
created by _any_ API key.

This is so that we can show a log of all notifications sent through the
API in the admin app.

It does not expose this list to the public `GET /notifications` endpoint
because this would violate our rules about keys only being able to get
notifications created with keys of the same type.
2016-09-22 11:17:46 +01:00
Martyn Inglis
fe5d53bd70 Ensure GET /notifications/ by service ID returns CSV and API data - used by ADMIN console.
- this is existing functionality mimicked.
2016-09-15 16:00:46 +01:00
Leo Hemsted
556b69a487 still return service if they have never sent any notifications 2016-08-24 15:00:51 +01:00
Leo Hemsted
29df7edaf9 tests for detailed services 2016-08-24 15:00:51 +01:00
Leo Hemsted
5491668579 let users set organisation on POST /service/{id} 2016-08-15 10:54:26 +01:00
Leo Hemsted
cc7ea8043c add organisation and branding to GET /service response dict 2016-08-12 11:40:57 +01:00