Commit Graph

515 Commits

Author SHA1 Message Date
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
Martyn Inglis
54e4311d1b Merged in the defensive code by mistake 2016-08-22 16:56:43 +01:00
Martyn Inglis
9fbd410474 Merge branch 'master' into use_new_template_stats_endpoint
Conflicts:
	app/notify_client/template_statistics_api_client.py
2016-08-22 16:47:42 +01:00
Martyn Inglis
f59e05fb1a Handle the API migration
If it;s the new format API hide the results

- Temp fix until new Admin code ships. Should be live for 5 mins.
2016-08-22 12:35:34 +01:00
Martyn Inglis
55c4443a05 Admin app uses the new API response formats. 2016-08-18 15:30:57 +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
6b5e64479a Add a page to set organisation and branding option
Platform admin only.

Adds radio buttons to choose one of:
- three hard-coded branding options
- organisations from a list provided by the API
2016-08-12 10:31:43 +01:00
Leo Hemsted
20c39d24b7 Merge pull request #863 from alphagov/allow-partial-service-updates
Allow partial service updates from service API client
2016-08-12 10:07:55 +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
6fc474a37f remove unused call to notification statistics 2016-08-11 12:07:50 +01:00
Leo Hemsted
3f3463b1ff Merge branch 'master' into remove-stats-from-send 2016-08-09 14:41:00 +01:00
Leo Hemsted
e2875ea66e Merge branch 'master' into remove-stats-from-send 2016-07-29 11:08:42 +01:00