Commit Graph

230 Commits

Author SHA1 Message Date
Martyn Inglis
08dc8fb13d Use the local APIClient rather than the one from the python-api-client
- ensures that all API calls set the request ID when talking to the API.
2016-11-30 17:01:44 +00:00
Martyn Inglis
202dd7d314 Override the BaseAPI Client
- This allows us to set a custom header for admin calls only (not needed in client calls)
- Adds request-id from Middleware to the API call to ensure the API logs against the same request ID.
2016-11-30 17:00:42 +00:00
Rebecca Law
1efa5530d4 Merge pull request #1027 from alphagov/deactivate-services-all-services-list
dont show inactive services on the choose service list
2016-11-23 16:10:44 +00:00
Rebecca Law
cebf8e1d65 Removed get_all_notifications method from notification_api_client as it is not longer being used. 2016-11-18 14:39:23 +00:00
Leo Hemsted
805639a2e1 add test for choose services and related redirects to it
it'll just show the add service button if you only have archived services
2016-11-16 13:18:49 +00:00
Leo Hemsted
08881e5bd1 add get_active_services method
* all current invocations of get_services now call get_active_services
  EXCEPT for platform admin page (where we want to see inactive services
* cleaned up parameter names and unpacking (since *params is unhelpful)
* fixed incorrect kwarg name in conftest
2016-11-16 11:08:20 +00:00
Leo Hemsted
63de598d31 Merge pull request #1008 from alphagov/deactivate-service
Deactivate service
2016-11-14 11:41:13 +00:00
Imdad Ahad
1da498164f Use POST req to update a user attr 2016-11-10 12:10:01 +00:00
Imdad Ahad
f3ca33dad3 Revert original update user method and add new attribute update (with strict checking) 2016-11-09 15:06:02 +00:00
Imdad Ahad
f14c3dbfa5 Stop passing the 'whole' user object when making changes to profile 2016-11-03 11:20:24 +00:00
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
Rebecca Law
a0e7d569e9 Send an email to the user when they change email address
This PR changes the flow to change an email address.
Once the user enter their password, they are told "Check your email".
An email has been sent to them containing a link to notify which contains an encrypted token.
The encrypted token contains the user id and new email address. Once the link is clicked the user's email address is updated to the new email address.
They are redirected to the /user-profile page.

Also in this commit is an update from flask.ext.login to flask_login.
2016-10-13 17:05:37 +01:00
Leo Hemsted
8464c67a3d move job statuses to job_api_client
prevent code duplication and a good excuse to use set subtraction
2016-10-11 10:35:33 +01:00
Leo Hemsted
dbe4400441 paginate jobs page
(only views/jobs/jobs.html, which is the drill-down page, not the dashboard view)
2016-10-10 15:43:01 +01:00
Leo Hemsted
be97edce7f make add_rate_to_jobs singular
there was no reason for it to operate on a whole list at a time
2016-10-10 15:43:01 +01:00
Leo Hemsted
549a17c1f7 separate get_job and get_jobs in job_api_client
also remove the status parameter, as we never use it anywhere
2016-10-10 15:43:01 +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
a04aad8825 Add additional params to get notifications client
We want to show a log of notifications that have been sent from the API.

The admin app uses its own private `/service/…/notifications` endpoint
for listing activity. This commit allows us to pass through two
optional, additional parameters to tell the API to:

- include or not include notifications created from a job
- include or not include notifications created with a test API key
2016-09-29 09:27:55 +01:00
Chris Hill-Scott
ce0b3511e6 Make indentation more sensible
Starting arguments on their own line and putting the closing parenthesis
on it’s own line because any subsequent changes to the arguments diff
cleanly (ie without touching any other lines).
2016-09-29 09:27:46 +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
imdadahad
69c16cb0e4 Merge pull request #936 from alphagov/fix-forgot-password-empty-user-issue
Fix exception raised when a pending user attempts to complete 'forgotten password' flow
2016-09-13 15:39:29 +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
Imdad Ahad
9eab8a726f - Add test to check that two-factor auth activates a user as expected
- Ensure DB user activation statusupdate only executed when required
- Fix test_should_activate_user_after_verify
2016-09-09 15:22:56 +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
93ca29eab8 Merge pull request #922 from alphagov/cancelled-jobs
Let users cancel a job
2016-09-06 17:12:19 +01:00
Chris Hill-Scott
eb11615a32 Add a cancel job button
If you schedule a job you might change your mind or circumstances might
change. So you need to be able to cancel it. This commit adds a button
on the job page which hits the `…/cancel` API endpoint for a job.
2016-09-06 16:55:24 +01:00
Martyn Inglis
2f56643e3a Fix up issues caused by merge
- statistics now on job_json
- removed test that validates we handle the case where job has no statistics key - never happens
2016-09-05 14:45:34 +01:00
Martyn Inglis
1ad2665bfe Merge branch 'master' into remove-code-that-handled-old-new-job-api
Conflicts:
	app/main/views/jobs.py
	app/notify_client/job_api_client.py
2016-09-05 14:29:58 +01:00
Martyn Inglis
5f561001eb Merged code from master / fixed conflicts 2016-09-05 13:39:03 +01:00
Chris Hill-Scott
7108646afd Revert "Revert "Remove check for statistics not being on job"" 2016-09-01 13:43:15 +01:00
Chris Hill-Scott
be90cf2783 Make sure create job client can handle statistics
The create job endpoint returns the data about the job with a `data:`
wrapper. This commit makes sure that, when the client is trying to
process a job which has just been created, it looks inside the `data`
wrapper.
2016-09-01 13:43:15 +01:00
Chris Hill-Scott
225a61ddd3 Add a component for picking the time to send a job
Users need to pick a time in the next 24hrs, or send a file immediately.

Rationale for this is a bit lost in time-before-holiday, but generally:

‘Now’ and ‘later’ as the inital choices makes it really clear what
this feature is about conceptually.

The choice of times is absolute, eg ‘1pm’ not ‘in 3 hours’
2016-08-31 16:58:09 +01:00
Chris Hill-Scott
d7a591836d Revert "Remove check for statistics not being on job"
This reverts commit 40e22d8258.

For some reason jobs don’t always have statistics.
2016-08-31 12:00:42 +01:00
Chris Hill-Scott
40e22d8258 Remove check for statistics not being on job
A job will always have statistics.

It’s always assigned:
bcfa83de79/app/job/rest.py (L48)

And the structure should always be the same, even if the counts are
zero because they’re generated from this query:
668e6c9716/app/dao/jobs_dao.py (L11-L22)

This line suggests that it’s a hangover from the aggregate tables:
8c159da3ea (diff-9886486bf41b0680d23588b190c252eaL24)

Since it’s no long necessary this commit removes it.
2016-08-31 10:46:43 +01:00
Chris Hill-Scott
37a1eb22b0 Use default dict for default job stats
This is just some refactoring.

`defaultdict` is a data structure which won’t raise a `KeyError` if you
try to access a key that doesn’t exist.

By passing `int` as the first argument, trying to access the value of
any key that doesn’t exists will return the value of `int()`, ie `0`
2016-08-30 14:59:23 +01:00
Chris Hill-Scott
7324b30dbc Re-add a 'requested' stat to a job
It’s useful to know how many notifications we’ve handed off to our
providers. This is a measure of how complete the processing of the job
is.

This is important, because once the job processing is complete then you
can accurately reconcile the report with the CSV file that you’ve
uploaded.
2016-08-30 14:57:28 +01:00
minglis
1651c72b3d Merge pull request #912 from alphagov/fix-dashboard-page
Fix dashboard page
2016-08-30 11:00:29 +01:00
Chris Hill-Scott
8ff70f0814 Merge pull request #904 from alphagov/make-settings-page-a-table
Make settings page a table and do a better job of explaining the reply to address/text message sender
2016-08-26 15:49:49 +01:00
Martyn Inglis
8c159da3ea Fix for admin app to show job data on dashboard page
- uses the new stats block in the API to build the stats expected by the dashboard page
- all work done in client
2016-08-26 15:21:10 +01:00
Leo Hemsted
4fbd23d5e9 Merge pull request #907 from alphagov/plat-admin
Platform admin stats rework
2016-08-26 13:51:36 +01:00
Martyn Inglis
fb9b33e3de Removed check on notifications-sent, that was used to check whether it was old or new style API.
Now new style is deployed it's not needed.

Tests updated to reflect this,
2016-08-25 12:54:23 +01:00
Leo Hemsted
b983f020ff remove old statistics_api_client
now unused - replaced mock fn with detailed_services too
2016-08-24 16:26:08 +01:00
Chris Hill-Scott
58b2a8a825 Make email branding settings a table
So that it matches the other settings on this page
2016-08-24 15:26:04 +01:00
Martyn Inglis
5b2ae43d5d Wrote some tests around the stats conversions.
Properly named the finished parameter.

Handled the root JSON key
2016-08-24 10:35:04 +01:00
Martyn Inglis
b5de1dae5e Merge branch 'master' into handle-new-jobs-api 2016-08-23 16:59:28 +01:00
Martyn Inglis
4a551329c5 Parse the JOB API response converting new style response to old style object
- allows migration of API
2016-08-23 16:58:50 +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