Commit Graph

223 Commits

Author SHA1 Message Date
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
b885ce9cf4 clean up some usage of active in tests and remove it from service_api_client.create_service (created services are always active) 2016-11-16 11:08:20 +00:00
Chris Hill-Scott
70eec8fe73 Don’t let people actually start a letter job
Who knows what would happen if a job with a letter template actually
got into the database. `403`ing the page is a quick and dirty hack to
stop this from happening.
2016-11-14 14:51:27 +00:00
Leo Hemsted
63de598d31 Merge pull request #1008 from alphagov/deactivate-service
Deactivate service
2016-11-14 11:41:13 +00:00
imdadahad
115cbe67e5 Merge pull request #1011 from alphagov/update-user-profile
Update user profile
2016-11-11 14:47:13 +00:00
Imdad Ahad
e5ea81b184 Fix pep issues and refactor tests 2016-11-10 10:45:09 +00:00
Imdad Ahad
1c42640137 Update update user mock to conform to new format 2016-11-03 11:20:43 +00:00
Chris Hill-Scott
274b2893f7 Merge pull request #979 from alphagov/4-days-scheduled
Allow a job to be scheduled any time in next 4 days
2016-11-03 10:24:07 +01:00
Leo Hemsted
e89f89bd11 remove unused delete service functionality 2016-11-02 10:29:44 +00:00
Leo Hemsted
e0fcb79b9b Merge branch 'master' of github.com:alphagov/notifications-admin into letters-flag 2016-10-31 14:04:05 +00:00
Chris Hill-Scott
4b0d8ec636 Use days of week, not month for scheduled jobs
Friday at 4pm is easier to understand than 14 October at 4pm, especially
when the UI you’ve used to choose this time has talked about days of the
week.
2016-10-31 09:14:05 +00:00
Imdad Ahad
a7e5285073 Add tests to ensure non gov user cannot see, access or create service 2016-10-28 10:48:29 +01:00
Leo Hemsted
f039397533 make letters error if user not logged in
also added tests for the various hiding logic points

also added new logged_in_client in conftest - so you dont need to
patch all those stupid API calls for get user and get service
2016-10-27 16:46:51 +01:00
Imdad Ahad
cd3a8bf533 Remove whitelist user fixture and refactor 2016-10-26 14:15:55 +01:00
Imdad Ahad
4203c7c250 Refactor creating a non-gov user 2016-10-26 14:03:18 +01:00
Imdad Ahad
bb85782230 Remove link for adding service if nonwhitelist user 2016-10-25 18:12:46 +01:00
Rebecca Law
f02bcd3338 Merge pull request #984 from alphagov/confirm-email-change
Send an email to the user when they change email address
2016-10-14 16:00:47 +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
e4f0656a32 remove filtering of test messages from jobs
this is now down on the api side
2016-10-12 13:54:22 +01:00
Leo Hemsted
0fdd38b9c5 add tests for new jobs functionality 2016-10-10 17:15:57 +01:00
Leo Hemsted
aa458a15da update tests to reflect new code
also change jobs.py to filter out test jobs (since we dont need to see em)
and to use the new statuses filter rather than filtering on front end
2016-10-10 15:43:01 +01:00
Leo Hemsted
441a2717f2 make dashboard jobs list hit job api twice
once for scheduled jobs, once for past jobs

this ensures that if you have lots of scheduled jobs it can still return your last 50 jobs
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
48891babc4 Add log of notifications to API integration page
Now that we’ve removed simulated notifications from the dashboard and
activity pages they’re not visible anywhere in the app.

While they should’t be visible to non-technical users, developers have
a real need for Notify to confirm that their code is doing what they
expect. This is needed especially when they’re just getting started with
Notify.

There’s no way of seeing this info from the API either, because a key
can only get notifications created with a key of that type.

It doesn’t make sense to make this a ‘mode’ of the dashboard or activity
because the information about notifications that developers need is
also different. So this commit adds up to 50 of the most recent
notifications sent via the API to the page that developers use as their
‘home’ page.

This also lets us explain the 7 days thing to developers via the
empty slate state of this area of the page.
2016-09-29 09:28:04 +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
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
311ae4cfa4 Sort services by newest created first
Other than which services are live it’s also interesting to know what
services are getting created on Notify. So let’s put the newest ones at
the top of the page.
2016-09-13 10:38:33 +01:00
Leo Hemsted
62868bc014 add test for id appearing in notification table
use new pytest yield fixture
2016-09-09 16:30:07 +01:00
Chris Hill-Scott
c94675f457 Don’t show cancelled jobs anywhere
The information about a job doesn’t make sense if a job is cancelled.

We could change the information to reflect that the job won’t be sent/
wasn’t sent/was cancelled, but there’s nothing you can really do with
this info.

So instead let’s:
- hide cancelled jobs from the dashboard
- hide cancelled jobs from the jobs page
- 404 the page if the user tries to click back enough times to hit the
  job page
2016-09-02 12:44:36 +01:00
Chris Hill-Scott
6921d8b59e Sort scheduled jobs so soonest is first
The scheduled job you probably care about the most is the soonest –
irrespective of when you scheduled it.
2016-08-31 16:59:24 +01:00
Chris Hill-Scott
31a032e678 Show message on job page if job is scheduled
If a job is scheduled then we can’t show the notifications yet, and the
progress report will stay at 0%.

In their place we should show what time a job will start.

Later on (when the API is ready) this area of the page should also show
a cancel button.
2016-08-31 16:58:52 +01:00
Chris Hill-Scott
4342b721f1 Show upcoming jobs on the dashboard
On the dashboard:
- adds a new ‘in the next 24 hours’ section to the dashboard which lists
  upcoming jobs
- tweaks some spacing on the dashboard so that it doesn’t look like too
  much of a mess
- don’t show scheduled jobs in the table of normal jobs

On the jobs page:
- don’t show scheduled jobs
2016-08-31 16:58:43 +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
bf872ab342 Base ‘% complete’ on notifications requested
The job is complete when all notifications are delivered or failed.

The report is complete once we have all notifications are in the
database.

This commit changes the meaning of the percentage from the former to the
latter. This is how it was before we removed the aggregate stats for
jobs.
2016-08-30 15:16:36 +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
Leo Hemsted
6ad7b019ea added tests for reworked platform admin page 2016-08-24 17:39:20 +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
Chris Hill-Scott
3719cdd115 Make settings page a table not a browse list
There’s no way of seeing what the current settings are for a service
without individually going to the pages where you can change them.

This commit replaces the list of settings with a table. The table plays
back the current value for each setting.

This is a pattern that has worked well on various services[1] as well
as on our own user profile page.

1. https://designpatterns.hackpad.com/Check-your-answers-page-2DSpTH9J0wU
2016-08-24 15:04:56 +01:00
Martyn Inglis
d56c14e147 Actually use the right exception class.
Two HTTPError classes exist. Need to use the one in notifications_python_client.
2016-08-24 12:12:19 +01:00
Martyn Inglis
d149a9691a Added tests for the 2 use cases:
used templates

unused templates
2016-08-24 12:09:38 +01:00
Martyn Inglis
c44a6cb65d Merge branch 'master' into new-api-for-deleting-templates 2016-08-23 09:31:05 +01:00
Martyn Inglis
9d25f326b0 Using new endpoint for template statistics
- gets notifications by template id, returning the most recent to illustrate the last use of that template.
2016-08-22 16:25:35 +01:00
Martyn Inglis
55c4443a05 Admin app uses the new API response formats. 2016-08-18 15:30:57 +01:00
Leo Hemsted
bfcf4be447 separate branding/org test into two tests
it's a bit more legible and the running time of these tests is
negligable so split up the test into its two logical components
2016-08-16 14:46:59 +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
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