Commit Graph

22 Commits

Author SHA1 Message Date
Leo Hemsted
a982144821 add deactivate service button on the service settings page
only visible for platform admins looking at active services.
no way to undo. no confirm button.
2016-11-02 16:53:40 +00:00
Leo Hemsted
e89f89bd11 remove unused delete service functionality 2016-11-02 10:29:44 +00:00
Leo Hemsted
730719b61f platform admins can toggle services from seeing letters 2016-10-26 16:56:51 +01:00
Chris Hill-Scott
b760457ba9 Add monthly breakdown of usage
Basically:
- shows all the months from start of given financial year to now or end
  of given financial year (whichever is earliest)
- shows a breakdown of free and paid text messages for each of these
  months

Depends on:
- [x] https://github.com/alphagov/notifications-api/pull/699
2016-10-05 16:11:19 +01:00
Chris Hill-Scott
3e42042156 Add a page to manage a service’s whitelist
Services who are in alpha or building prototypes need a way of sending
to any email address or phone number without having to sign the MOU.

This commit adds a page where they can whitelist up to 5 email addresses
and 5 phone numbers.

It uses the ‘list entry’ UI pattern from the Digital Marketplace
frontend toolkit [1] [2] [3].

I had to do some modification:
- of the Javascript, to make it work with the GOV.UK Module pattern
- of the template to make it work with WTForms
- of the content security policy, because the list entry pattern uses
  Hogan[1], which needs to use `eval()` (this should be fine if we’re
  only allowing it for scripts that we serve)
- of our SASS lint config, to allow browser-targeting mixins to come
  after normal rules (so that they can override them)

This commit also adds a new form class to validate and populate the two
whitelists. The validation is fairly rudimentary at the moment, and
doesn’t highlight which item in the list has the error, but it’s
probably good enough.

The list can only be updated all-at-once, this is how it’s possible to
remove items from the list without having to make multiple `POST`
requests.

1. 434ad30791/toolkit/templates/forms/list-entry.html
2. 434ad30791/toolkit/scss/forms/_list-entry.scss
3. 434ad30791/toolkit/javascripts/list-entry.js
4. http://twitter.github.io/hogan.js/
2016-09-29 09:27:38 +01:00
Chris Hill-Scott
92aacc1a54 Remove extraneous arguments to super
> dont need self.__class__, self in super - that's a python 2.x crutch.
> super() is equivalent
2016-09-12 14:59:53 +01:00
Chris Hill-Scott
5fda35c89d Make it clear that client do not use __init__
The clients never get passed useful values to their `__init__` methods.
Rather the real values are passed through later using the `init_app`
method.

So it should be an error if the client is relying on the values that
get passed to it’s init method. Easiest way to ensure this is by making
the `__init__` method not expect any arguments and passing fake values
to the `Super` call.
2016-09-12 12:18:19 +01:00
Chris Hill-Scott
fa5e5475e9 Update Python client
Just so that nobody else has to do it.

Implements:
- [x] https://github.com/alphagov/notifications-python-client/pull/29

Which is a breaking change requiring the renaming of method arguments.
2016-09-08 15:55:07 +01:00
Chris Hill-Scott
0f6a090470 Fix admin app putting service into research mode
We changed the `update_service` method to only update indivdual
attributes of a service, and only allow it to update specified
attributes: 0cfe10639a

We neglected to specify `research_mode` as one of the allowed
attributes.

This broke the app’s ability to put a service in or out of research
mode.

This commit:
- makes sure the tests cover this eventuality
- fixes the bug by specifying `research_mode` as one of the allowed
  attributes
2016-08-23 10:16:27 +01:00
Leo Hemsted
fde8d81868 send organisation back in correct variable 2016-08-15 11:15:49 +01:00
Leo Hemsted
fb510d2522 only set organisation on GET and add allowed fields to service client
we were overwriting it before validating the form for POST, so lost info
2016-08-12 12:37:18 +01:00
Chris Hill-Scott
955566b127 Don’t allow changing service users on update 2016-08-11 17:10:10 +01:00
Chris Hill-Scott
da1fa2e61c Make _attach_current_user a pure function
Mutating dictionaries is gross and doesn’t work as you’d expect. Better
to have the function return a new dictionary instead.

Means we can be explicit that `created_by` is one of the allowed params
when updating a service.
2016-08-11 17:07:55 +01:00
Chris Hill-Scott
0cfe10639a Only allow update service to modify named attrs
To prevent typos and inadvertently updating something we shouldn’t,
this adds some filtering to the update_service method to make sure it
is only allowed to update certain attributes of a service.
2016-08-11 17:07:43 +01:00
Chris Hill-Scott
002b58a062 Make service API client do partial updates
The service API client was updating every attribute of a service. Which,
while kinda clunky, is fine…

…until something calling it doesn’t pass in every attribute of the
current service. It was then defaulting optional parameters to `None`.
Which resulted in a bug whereby every time a service was set to live,
its `reply_to_address` and `sms_sender_name` got overwritten to be
empty.

This commit changes the `update` method to only require the service ID,
and pass whatever other named arguments it received straight through to
the API. The API handles partial updates just fine (I think).
2016-08-11 17:07:33 +01:00
Leo Hemsted
3f3463b1ff Merge branch 'master' into remove-stats-from-send 2016-08-09 14:41:00 +01:00
Leo Hemsted
4ea23a7484 move away from statistics_api towards service_api 2016-07-29 10:28:18 +01:00
Leo Hemsted
eaf9b6dc54 pass 'today_only' flag to the back-end from send page
also bump notification-utils requirement to 8.7.0 for changes
to RecipientCSV
2016-07-25 15:26:43 +01:00
Leo Hemsted
0accd88869 request stats for today from send page from GET /service/:id endpoint
also amended test cases to ensure they mock out correct call
2016-07-25 14:46:27 +01:00
Leo Hemsted
3ffd6c744c separate detailed and normal service_api_client.get_service
to make it easier to mock and control return values
2016-07-20 14:12:22 +01:00
Leo Hemsted
4451a8634d add detailed flag to GET service api client
returns current (past 7 days) notification stats as well as service info
2016-07-20 14:12:22 +01:00
Leo Hemsted
1cd2841c17 rename api_client to service_api_client 2016-07-15 15:23:23 +01:00