Commit Graph

2259 Commits

Author SHA1 Message Date
Chris Hill-Scott
1073b8f178 Merge pull request #2178 from alphagov/cache-has-jobs
Check if any jobs exist before querying jobs
2018-07-31 11:17:42 +01:00
Chris Hill-Scott
0906eb019d Check that API is not called when result is cached
Good to explicitly test this (rather than relying on an exception not
being raised).
2018-07-31 10:05:10 +01:00
Chris Hill-Scott
1304561a70 Use service model to look up service attributes
This is better than just keying into the JSON because it means you get
an exception straight away when looking up a key that doesn’t exist
(which via mocking you could ordinarily miss).
2018-07-30 14:56:36 +01:00
Chris Hill-Scott
036923c382 Make a service model and use for permissions
Having the service floating about as JSON is a bit flakey. Could easily
introduce a mistake where you mistype the name of a key and silently
get `None`.

Also means doing awkward things like `if 'permission' in
current_service['permissions']`, whereas for users we can do the
much cleaner `user.has_permission()`.

So this commit:
- introduces a model
- adds a `.has_permission` method similar to the one we have for users
2018-07-30 14:56:36 +01:00
Chris Hill-Scott
19632ea4ab Add option to copy existing template when adding
Sometimes when setting up a service you might have a few very similar
templates, in which only a small amount of content. Or you might even
have a few of services, which are used by different teams but have
similar templates.

Copy and pasting, especially from one service to another, is a pain.
This commit makes it easier by allowing users to copy an existing
template when choosing to add a new one, instead of starting from
scratch.
2018-07-30 11:31:51 +01:00
Chris Hill-Scott
505de52d38 Check if any jobs exist before querying jobs
At the moment the dashboard does two API calls to find out if a service
has:

1. Scheduled jobs
2. Normal jobs

API calls are slow because they are synchronous, go over the network and
touch the database. We can’t cache these API calls because:
- a scheduled job could become a normal job at any time
- the statistics on a normal job are constantly updating

However there are plenty of services which don’t have any jobs, and
probably never will. And finding out if a service has any jobs is
reliably cacheable (because as soon as a service creates its first job
it has some jobs).

So this commit:
- refactors the way we get scheduled/normal jobs into the job_api_client
  to make the view a bit slimmer
- makes an additional, Redis-wrapped call to find out if any jobs exist
  before trying to get the jobs

This should result in a speedup on the dashboard, and can be used in the
future if there’s anywhere else we want to show or hide something
depending on whether a service has created any jobs (I have some ideas).
2018-07-30 11:14:01 +01:00
Pea Tyczynska
6d2aad5561 Remove functions and comments redundant after monthly_billing removal 2018-07-25 11:48:17 +01:00
Rebecca Law
e806cf036e [WIP]
New service_api_client to get stats for variable days
2018-07-25 10:47:29 +01:00
Chris Hill-Scott
7d535544db Merge pull request #2164 from alphagov/rename-basic-nav
Improve navigation in basic view
2018-07-20 14:54:15 +01:00
Rebecca Law
e89ae1d2ec Added missing assert 2018-07-19 11:42:34 +01:00
Rebecca Law
ce754be464 Addressing comments from PR review.
Update tests
Use a table to display the data retention data.
2018-07-18 15:31:34 +01:00
Katie Smith
eb9e9fac3b Ensure one-off jobs do not appear on message log page
Upcoming changes to API will mean that by default its
`get_notifications_for_service` DAO function will return one-off
notifications. In most cases this is what we want, but the message log
page should not show one-off notifications. By passing in the `include_one_off=False`
option to API we can ensure that this page will stay the same when API
changes.
2018-07-18 08:11:42 +01:00
Rebecca Law
be51a668cf Fix capitalisation on Data Retention 2018-07-17 15:56:28 +01:00
Rebecca Law
c2f973da95 Added unit test for the data retention pages. 2018-07-17 15:50:40 +01:00
Rebecca Law
4b8b571a87 Adding views to view, add and edit service data retention policies.
Only visible to a platform admin.
A service can have a custom number of days to retain the notification data for each notification type.
2018-07-17 14:39:04 +01:00
Pea Tyczynska
2fab363253 Link to user services on User Information page 2018-07-16 17:37:26 +01:00
Pea Tyczynska
b3d99507bd Fix displaying of services on User Information page 2018-07-16 17:37:26 +01:00
Pea Tyczynska
8258de084c Change part of the tests to use client_request
Two tests retained the old syntax because of mocker conflict:
when logging in as a user through client_request, it sets up a
side_effect on user_api_client.get_user to the user you log in
as. If you later want to set return_value for get_user to
something else, problems start :d.
2018-07-16 15:37:53 +01:00
Chris Hill-Scott
b946a6008d Add H1 to sent messages page
> Suggest making the H1 visible here for consistency, but also to make
> it clear to users what they’re looking at.

> This screen is similar to – but not exactly the same as – the
> individual text, email and letter dashboard screens from Admin view,
> so the H1 could help to distinguish it from them for users who may
> have interacted with both.
2018-07-13 17:02:27 +01:00
Chris Hill-Scott
ca9fe6c8f6 Rename ‘Send a message’ to ‘Templates’ in basic view
From Karl:

> Templates – this should be consistent with Admin view. Users may
> switch from Basic to Admin view (or vice versa), they will also
> interact with users who have a different view or permissions to them.
> Neither should have to learn new interfaces and language if possible.

> ‘Send a message’ was a nice, active label – but Notify options aren’t
> usually actions. If we’re going to change this we should be consistent
> across both Admin and Basic views.

> For the same reason, I have rejected ‘see’, ‘search’ and ‘view sent
> messages’. It will be interesting to see in user testing whether users
> read ‘sent messages’ as ‘send messages’.
2018-07-13 17:02:27 +01:00
Pea Tyczynska
4cd465753a Add view that displays user information, including:
- name
- email
- phone number
- services
- last login
- failed login attempts if any

The view can be accessed from results of find_users_by_email

logged_in_at added to User serialization on admin frontend as
a part of this work
2018-07-13 16:01:52 +01:00
Pea Tyczynska
57e9c1d6e6 Validate against empty form submission for find_users_by_email
This included:
- creating a new form SearchUsersByEmailForm with validation
on its search field

- introducing 400 status to the view  if the form does not validate

- fixing the POST request data structure in the tests (it was
incorrect before and uncaught due to lack of validation and mocking
the response from the API.
2018-07-13 11:58:29 +01:00
Pea Tyczynska
d1a05e2ec5 find_users_by_email view calls API and feeds results to template
Template then displays the results.

Page displays a message if no results found
2018-07-13 11:58:29 +01:00
Pea Tyczynska
ea6a5b6e7d find_users_by_email view loads a page with search form and is linked to 2018-07-13 11:58:28 +01:00
Katie Smith
a5124f4af1 Sanitise csv filenames before saving to S3
Commit 58cc1604a7 sanitises any non-ascii
characters in the headers. CSV filenames get used as a header value, so
this fixed a bug that occurred when non-ascii characters were used.

The CSV filename also gets used as part of the metadata when uploading
the file to S3. Since the S3 metadata can only contain ASII characters,
we also need to sanitise the filename before uploading it to S3.
2018-07-12 15:19:45 +01:00
Chris Hill-Scott
7f0a13e9aa Merge pull request #2136 from alphagov/guess-name
Guess people’s names when they’re invited
2018-07-11 16:11:58 +01:00
Chris Hill-Scott
660fadbce7 Make the guessing a bit more sophisticated
Things we’ve noticed from looking at real data that we could handle in a
smarter way:
- removing numbers (there might be a tom.smith2@dept.gov.uk if tom.smith
  is already taken)
- removing middle initials (again, these tend to be used for
  disambiguation and aren’t included when we ask people for their names)
- ignoring email addresses which only have someone’s initial, not their
  first name (because we can’t make a decent guess in this case)
2018-07-11 13:31:38 +01:00
Katie Smith
3f117bd7b1 Merge pull request #2152 from alphagov/remove-old-platform-stats
Use new platform-admin page
2018-07-11 11:15:59 +01:00
Chris Hill-Scott
5c5e0bac02 Stop email address wrapping 2018-07-11 10:35:25 +01:00
Chris Hill-Scott
3683f99c3b Guess people’s names when they’re invited
Most people’s names, especially in government are in the format
firstname.lastname@department.gov.uk. This means that you can pretty
reliably guess that their name is ‘Firstname Lastname’.

When users are invited to Notify we know their email address already.

So this commit pre-populates the registration form based on this guess.

This is a nice little detail, but it should also stop the browser
pre-filling the name field with someone’s email address (which I think
happens because the browser assumes a registration form will have an
email field).
2018-07-11 10:35:25 +01:00
Chris Hill-Scott
d08e2b7ee3 Merge pull request #2156 from alphagov/hide-7-days-bsic
Hide ‘7 days’ paragraph from basic view
2018-07-10 17:24:48 +01:00
Chris Hill-Scott
ed9444b436 Fix org info in branding requests with known orgs
This wasn’t looking quite right in the case where an organisation is in
our list of domains.
2018-07-10 17:18:50 +01:00
Chris Hill-Scott
3902d0a05c Hide ‘7 days’ paragraph from basic view
It looks too prominent as a paragraph on the page. This commit moves
the info about how long we keep data for into the ‘empty’ message we
show when there are no results (ie the message people will see if they
search for something that was sent more than 7 days ago).
2018-07-10 17:08:02 +01:00
Chris Hill-Scott
47e83c6922 Merge pull request #2155 from alphagov/add-org-info-to-branding-requests
Add organisation info to branding requests
2018-07-10 16:56:34 +01:00
Chris Hill-Scott
949bf6feea Add organisation info to branding requests
This will let us know which organisation the person asking for the
branding is from. This should reduce how often we have to go back to
them and ask.
2018-07-10 16:34:44 +01:00
Chris Hill-Scott
199c699e11 Hide download all link in basic view
Can’t think of a good reason why someone who is only sending messages
would need a download of all the messages their entire team has sent.

Most of the ‘caseworking’ teams have been getting on fine without this
link; it’s only recently we brought it back.
2018-07-10 15:59:24 +01:00
Katie Smith
3bbc73dfd2 Use new platform-admin page
We had kept the original platform-admin page at `/platform-admin` and
created a new page, `/platform-admin-new` for the new platform admin
page. Now that the numbers on both pages look ok we no longer need both
pages, so can replace the original page.
2018-07-10 14:39:54 +01:00
Chris Hill-Scott
ce9c5ca892 Merge pull request #2151 from alphagov/add-basic-preview
Add a preview of basic view
2018-07-10 14:38:02 +01:00
Chris Hill-Scott
95d138b638 Add a preview of basic view
One of the big things we found in user research was that people were
uncertain what the effect of giving someone basic view was.

So in the spirit of ‘show don’t tell’, this commit adds a way for users
to preview basic view. They can go into the preview and click around as
much as they like, just as if they really had the basic view assigned to
them.

Once they have seen enough they can return to the settings page where
they can decide whether or not to switch basic view on for real.
2018-07-10 14:24:02 +01:00
Chris Hill-Scott
0008d7cda7 Rename ‘caseworker’ to basic view on team members
Missed this in https://github.com/alphagov/notifications-admin/pull/2146
2018-07-10 12:17:22 +01:00
Chris Hill-Scott
2f40ddae20 Remove platform admin toggle for basic view
Since platform admins can use the new settings page, this commit:
- links to that page
- removes the platform-admin-only endpoint that switches basic view on
  and off
2018-07-10 11:45:50 +01:00
Chris Hill-Scott
4d3a4ef9af Add form to let users switch basic view on and off
This commit adds radio buttons to the ‘basic view’ page. This will let
users choose whether basic view is on or off for their service.

As before, this page will only be linked to if a service already has
basic view, so this commit does not launch the new feature.
2018-07-10 11:44:40 +01:00
Chris Hill-Scott
a6662b3f59 Add basic view to the settings page
This commit adds:
- a row to the settings page…
- …which links to a page explaining what basic view is

The new row (and link) will only appear for services who already have
the feature switched on. This is because we are not launching the
feature yet, so it shouldn’t be available to just anyone.
2018-07-10 11:44:40 +01:00
Chris Hill-Scott
5794a54385 Rename ‘caseworker’ to ‘basic view’
‘Caseworker’ was a bad name because it:
- suggested that Notify might be expanding into case management
- may or may not map to someone’s actual role, in a confusing way (this
  is why ‘manager’ is also a bad name)

‘Basic view’ is the best name we could come up with because:
- it describes the purpose of feature, not the user
- a ‘view’ changes what you can _see_ as much as it changes what you can
  do

Admin remains a good word – in research users self-describe their use
of Notify in using it. This commit makes the name ‘admin view’ to match
‘basic view’.

This also means we can hide the legend for this fieldset because the
choices are self-explanatory.
2018-07-09 10:39:09 +01:00
Chris Hill-Scott
b1aac841f4 Merge pull request #2042 from alphagov/allow-remove-callback
Allow callbacks to be removed
2018-07-06 14:52:07 +01:00
Leo Hemsted
4d4424657f allow you to remove URL without removing bearer token 2018-07-06 11:47:35 +01:00
Chris Hill-Scott
b21c0da683 Make sure caseworking users clear their invite
There was a bug where caseworking users skipped the part of the invite
flow where their invite was cleared from the session. This caused
a 500 if they later tried to create another service.

This commit makes sure that both types of user have the invite cleared
from the session after accepting it.
2018-07-05 13:40:40 +01:00
Chris Hill-Scott
9da9e85293 Remove letters from caseworking view
Because one-off letters aren’t a thing yet there’s no way for
caseworkers to send letters. So showing them letter templates will just
confuse them.
2018-07-05 11:53:42 +01:00
Chris Hill-Scott
0018ecd765 Hide ‘Use my email address/phone number link’
This link is useful for people who are setting up templates and want to
test out how they look/how Notify works.

‘Caseworker’ users shouldn’t need to send themselves messages on a
regular basis, so this link is another thing we can take away.
2018-07-05 11:53:42 +01:00
Chris Hill-Scott
b0cb9ff58e Add sent notifications page for caseworkers
The other task that caseworkers have to do (much less often than sending
messages) is look at the messages which they’ve sent. The reason for
doing this is usually to find a specific message which someone has
complained about.

This commit adds:
- a page where they can do that
- a navigation item so they can get to that page

We reckon that because this is about finding specific messages, not
reporting that it’s fine to mush all the channels (email, text, letter)
into one table.
2018-07-05 11:53:42 +01:00