Commit Graph

2056 Commits

Author SHA1 Message Date
Pea Tyczynska
4fe239abb2 Add support for new template statistics API response
The new API response for template statistics returns separate
count for each status. We get rid of template stats for cancelled
notifications and group the rest of the statuses together.
2019-01-15 16:22:27 +00:00
Alexey Bezhan
46bfb541c8 Group new template-statistics response by template
New API template-statistics response returns notification counts for
each template and status combination. This can be used for both
service statistics counts and template statistics by grouping the
counts either by status or by template.
2019-01-15 15:55:04 +00:00
Chris Hill-Scott
309de074c3 Don’t give postage choice on service and template
We are moving from the postage being set on the service to being set on
the template. Once a service has been migrated to have the new
permission they should no longer be able to set the postage at a service
level, only at the template level.
2019-01-15 12:06:56 +00:00
Katie Smith
da50f77538 Show error message if precompiled PDF cannot be opened
If PDF files have a validation error which means that they can't be
opened by PyPDF2 we would previously show the 500 status error page. We
now catch PyPDF2.utils.PdfReadErrors so that we can display a custom
error message on the notification page instead.
2019-01-09 13:10:36 +00:00
Chris Hill-Scott
206a7806d4 Allow users to navigate folders when copying
We already have a pattern for navigation folders and searching for
templates – let’s use it for the copy page too. And I reckon we can
represent services as folders if the user has multiple services they
could copy a template from.
2019-01-08 12:21:32 +00:00
Chris Hill-Scott
39506c4794 Rename ‘All templates’ 2019-01-04 15:15:58 +00:00
Tom Byers
9bce22f766 Swap order of move_to validators
If Optional runs before required_for_ops, it stops
the validation chain so it doesn't get to
required_for_ops. The move_to field isn't required
for the 'move-to-new-folder' operation, so this has
been removed.

This also adds comments explaining why we set
default to an empty string when instantiating the
move_to field.
2019-01-03 17:09:00 +00:00
Katie Smith
3cf36c592f Change move folder form to not have default radio btn and to show hint
Updated the move folder form to add a hint for the radio button for the
current folder saying 'current folder'. This hint does not get shown if
you are viewing all folders (so you are not inside a folder).

Also stopped a default radio button from being selected on the form.
2019-01-03 16:51:47 +00:00
Tom Byers
501ec2a534 Make all options descend from 'all templates' 2019-01-03 16:51:47 +00:00
Tom Byers
3c4a186a25 Display the template folders nested on the move template/folder form
Before, all the folders were displayed in a list which was ordered but
not nested. This changes the move form to nest the template folders.
2019-01-03 16:51:47 +00:00
Pea (Malgorzata Tyczynska)
5d99b2d2f6 Merge pull request #2616 from alphagov/choose_postage
Choose and display postage on template
2019-01-02 15:39:15 +00:00
Pea Tyczynska
97058d3c5b Add service setting switch to choose postage per template 2018-12-27 18:05:30 +00:00
Pea Tyczynska
50935e79ca Test mock_update_service_template called with right args 2018-12-21 17:18:18 +00:00
Pea Tyczynska
85b8b343e2 Service deafault radio checked by default, existing tests pass. 2018-12-21 17:13:18 +00:00
Pea Tyczynska
695f1150b5 service_default postage resets template postage to None 2018-12-19 12:24:02 +00:00
Pea Tyczynska
687e9e5866 Change postage while editing template 2018-12-18 18:22:03 +00:00
Pea Tyczynska
a60d269900 Show postage on template page if service can choose postage and
postage set on the template.
2018-12-18 15:52:53 +00:00
Leo Hemsted
94da05ebc4 only catch HTTPError
also add tests
2018-12-17 15:25:27 +00:00
Leo Hemsted
5c3c4ec78c change error message for not selecting a template
needed to subclass RadioField for this
2018-12-17 15:25:27 +00:00
Leo Hemsted
6f8dc7e6d3 fix being able to add template without selecting a radio button 2018-12-17 15:25:27 +00:00
Leo Hemsted
180654046a flash error message when moving folder to itself 2018-12-17 15:25:27 +00:00
Chris Hill-Scott
5ec673b84d Merge pull request #2578 from alphagov/add-existing-live-to-go-live
Note existing live services in go live ticket
2018-12-13 10:43:57 +00:00
Chris Hill-Scott
b51410baba Merge pull request #2575 from alphagov/remove-commas-volumes
Strip commas from estimated volumes
2018-12-13 10:41:50 +00:00
Chris Hill-Scott
a8b916b57f Refactor gov user check into a decorator
We quite often use it in the same way as `@user_has_permissions`.
2018-12-12 13:42:26 +00:00
Chris Hill-Scott
9a70f6a7f4 Don’t let non-government users request to go live
Only users who work for government can accept the terms of use. This
will save us from having to email these requesters back telling them
they need to find someone else to submit the request.
2018-12-12 12:56:13 +00:00
Chris Hill-Scott
126db71de6 Refactor government user check onto model 2018-12-12 12:29:08 +00:00
Chris Hill-Scott
688bdd1d7a Note existing live services in go live ticket
It’s useful for analysing our growth to know if someone who’s requesting
to go live is already a live user of Notify.
2018-12-12 12:22:38 +00:00
Chris Hill-Scott
3cb0b164e8 Strip commas from estimated volumes
We suggest people format their numbers with commas when telling us how
many things they’re going to send.

This causes problems when we paste these values into a spreadsheet,
because the commas get interpreted as column separators.
2018-12-11 10:47:28 +00:00
Chris Hill-Scott
184a9fa605 Use email fields for feedback form
Otherwise we can end up collecting invalid email addresses…

This required some refactoring to allow our email fields to be optional
(but not by default).
2018-12-07 13:11:41 +00:00
Chris Hill-Scott
971c64a0a9 Merge pull request #2553 from alphagov/better-live-search-team
Scope live search on team page to name and email
2018-12-05 16:46:15 +00:00
Chris Hill-Scott
d81af78977 Merge pull request #2559 from alphagov/template-js
Template folder form smart JS
2018-12-05 16:36:12 +00:00
Katie Smith
31956999e2 Merge pull request #2562 from alphagov/allow-letters-to-be-cancelled
Allow letters to be cancelled
2018-12-05 16:07:46 +00:00
Chris Hill-Scott
58a25e1e9e Merge pull request #2560 from alphagov/fix-none-email-branding-preview
Fix email branding preview for no branding
2018-12-05 11:59:48 +00:00
Chris Hill-Scott
d4a9fb52a5 Use normal radio field for add template choices
It doesn’t have a ‘none’ option.
2018-12-05 11:31:02 +00:00
Chris Hill-Scott
c7f34cc211 Fix email branding preview for no branding
The value that means no branding (in the form) has changed from `'None'`
to `'__NONE__'`.

This commit:
- accounts for that value
- makes sure that no branding (ie plain GOV.UK) is still displayed when
  no query argument is given
2018-12-05 11:28:10 +00:00
Katie Smith
5406efa0cc Add link to cancel letters
Added a link to cancel letters from the letter notification pages if the
letter is still able to be cancelled. Clicking on this link will show a
confirmation box, and will then cancel the letter if the user confirms.
2018-12-05 11:12:05 +00:00
Leo Hemsted
97f663f99e change operations to kebab-case
so that they better align with the front-end, where they'll be used in
data attributes. Also, making the kebab case is nice because it doesn't
give favouritism to either JS or python naming conventions
2018-12-04 16:41:47 +00:00
Leo Hemsted
05de491c0c pre-check templates/folders that were checked previously
(when rendering an error)
2018-12-04 16:41:47 +00:00
Leo Hemsted
1a5ebb3e62 Merge pull request #2541 from alphagov/choose-new-template
Let users add new template from the choose page
2018-12-04 16:41:38 +00:00
Pea (Malgorzata Tyczynska)
050f768996 Merge pull request #2556 from alphagov/one_off_bug_bug
Correct argument name to mobile_number on is_current_user_the_recipient
2018-12-04 11:30:55 +00:00
Alexey Bezhan
b787ca6e5b Add Service.get_days_of_retention helper method
Data retention lookup by type is only performed to get the number
of days, so we can update the service method to return the number
or the default directly.
2018-12-03 18:04:58 +00:00
Alexey Bezhan
7a7a9ae854 Cache service data retention in Redis
Adds caching for service data retention. This removes separate API
client methods to retrieve individual data retention records by id
or type in favor of a single method that fetches and caches all
retention settings configured for the service. This makes it much
easier to invalidate cache when settings change.

Lookup by id or type is provided by helper methods in the service
model.
2018-12-03 17:57:02 +00:00
Pea Tyczynska
a21b398efd Correct argument name to mobile_number on is_current_user_the_recipient 2018-12-03 17:53:47 +00:00
Chris Hill-Scott
2fcf278a5b Use unambiguously magic value for None choices
WTForms coerces `None` as a choice to `'None'` as a string when
rendering form fields (form fields will only ever have string data
because that what the browser posts back).

But internally WTForms coerces `None` to mean an unset value, ie where
the user hasn’t selected a radio button:
283b280320/src/wtforms/utils.py (L1-L20)

We shouldn’t use `None` to mean two different things. And in fact we
can’t, because it in effect means that we’re always getting a value
for the `move_to` field, even if the user hasn’t chosen to move any
templates. Which results in some very expected behaviour.
2018-12-03 17:49:10 +00:00
Chris Hill-Scott
4c148c7c23 Look at other services only if no templates
This saves one call to the API or Redis in the common case where the
current service does have templates.

This is because `any()` evaluates all expressions before running,
whereas `or` will only evaluate the second expression if the first
returns `False`-y.
2018-12-03 17:38:38 +00:00
Chris Hill-Scott
8d0b3f47fd Set form choices as a list, not an iterator
Iterators can be exhausted, causing options to unexpectedly disappear
from the radio buttons.
2018-12-03 17:38:37 +00:00
Chris Hill-Scott
10100e51b6 Let users add new template from the choose page
Since we’re letting users add new folders directly from the choose page
it makes sense that they should also be able to add templates from
there.

This resolves the problem we saw in user research where people found it
hard to know where to go to add a new folder when they were all behind
one green button.
2018-12-03 17:38:37 +00:00
Pea (Malgorzata Tyczynska)
8aeea9929f Merge pull request #2551 from alphagov/one_off_bug
Back button on one-off message preview takes user to their flow
2018-12-03 17:12:58 +00:00
Chris Hill-Scott
8807028097 Refactor team members into the model
Follows the pattern we’re using elsewhere of having less logic in the
view methods.
2018-12-03 12:07:58 +00:00
Chris Hill-Scott
538a06c0bf Refactor filtering out accepted invites to client
None of our model or view layer code should need to know about accepted
invites. We don’t use them anywhere because once an invite is accepted
that person is now a user.

Putting this logic in the client means that:
- none of the code calling the client needs to care about accepted
  invites
- it’s easier to (if we want) update the API code to not return accepted
  invites
2018-12-03 11:06:03 +00:00