Commit Graph

371 Commits

Author SHA1 Message Date
Chris Hill-Scott
7d7b790dc1 Remove add template as separate page
This has moved to the choose template page.
2019-02-11 17:55:58 +00:00
Chris Hill-Scott
3a5bfeb7aa Remove folders feature flag
Every service has this feature now[1] so we don’t need to check whether
or not it’s switched on any more.

1. https://github.com/alphagov/notifications-api/pull/2286
2019-02-11 17:55:57 +00:00
Leo Hemsted
f83910599c remove option for branding to sometimes not show search
it wouldn't show search if there were under a certain amount of letter
or email branding options - however we know there will always be more
than that amount so lets remove some complexity.

Also, rename the SearchTemplatesForm because it can search anything -
it just prompts you to search by name is all.
2019-02-07 11:39:23 +00:00
Leo Hemsted
8266635a7a remove dvla_organisation and other unused things
dvla_organisation, branding_dict, a weird `branding` property on
update_service. all gone 💥
2019-02-07 11:38:20 +00:00
Leo Hemsted
a1caf77b0e use new letter branding instead of dvla organisation id
new code is copied stylistically from the email branding patterns.
Instead of `service.dvla_organisation`, there's now
`service.letter_branding` and `service.letter_branding_id`. However,
unlike email branding we're not currently showing a preview of the
logo. That can come later when we work out how we want to do it.
2019-02-07 11:30:18 +00:00
Leo Hemsted
0e20ca44a3 rename branding to email_branding
to help transition to having letter branding as well
2019-02-07 11:30:18 +00:00
Katie Smith
529d7df5f5 Add page to create new letter branding
This has a form with 3 fields - the file upload field, logo name, and an
optional logo domain. Logos need to be uploaded in `.svg` format and we
then convert this to `.png` format and upload both file types to S3 as
well as saving the letter branding details in the database.
2019-02-06 17:26:58 +00:00
Pea Tyczynska
fe6b73b8dc Remove service postage setting and choose_postage switch 2019-02-04 14:55:16 +00:00
Pea Tyczynska
20ae200de9 Remove choosing postage from edit template content flow 2019-02-04 14:45:33 +00:00
Pea Tyczynska
db5378bac2 Edit template postage from a separate view 2019-02-04 14:45:33 +00:00
Chris Hill-Scott
3b15b04fc2 Let users switch channels on and off by themselves
We let people do this for letters already. We should let them do it for
emails and texts too, rather than have to email us.
2019-01-29 16:05:32 +00:00
Katie Smith
5b77329e63 Validate name field on ServiceUpdateEmailBranding form
This introduces a validator to validate that the name field is not empty
on the ServiceUpdateEmailBranding form, but only if the form details are
being submitted. If a file is being uploaded, the name is allowed to be
empty.
2019-01-29 11:37:27 +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
85b8b343e2 Service deafault radio checked by default, existing tests pass. 2018-12-21 17:13:18 +00:00
Pea Tyczynska
687e9e5866 Change postage while editing template 2018-12-18 18:22:03 +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
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
d81af78977 Merge pull request #2559 from alphagov/template-js
Template folder form smart JS
2018-12-05 16:36:12 +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
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
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
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
Leo Hemsted
1bb7e98722 add fieldsets to template/folder form and update docstrings
also remove erroneous pytest.ini cfg and reset button
2018-11-28 14:14:20 +00:00
Leo Hemsted
d07de58cd9 split out new folder into two separate forms
move_to_new_folder and add_new_folder are now two separate html fields
and form items - so that we can more easily manipulate them on the
front end
2018-11-28 14:14:20 +00:00
Leo Hemsted
690585c017 move add new folder and move to folder into one dialog box
this lets us combine the two actions to create "Move to a new folder".
If the user hits enter rather than clicking a button, there is a hidden
submit button that (for now) prevents them from taking any action.
A future commit will try and understand what the user might be doing
based on which fields are populated/selected.
2018-11-28 14:14:20 +00:00
Chris Hill-Scott
ee991d0142 Allow any sub-items to be moved from a folder
Since you can now see them when searching you should also be able to
select and move them. Which means that they needed to be included in
the `Form`’s list of possible choices of things to move.
2018-11-23 16:29:21 +00:00
Leo Hemsted
3551d36f32 bump reqs 2018-11-14 13:35:24 +00:00
Chris Hill-Scott
872b3f9c94 Make existing_keys a required argument
Because we should always expect its presence, even it’s an empty list.
And because having mutable default arguments can have nasty side
effects.
2018-11-13 14:27:01 +00:00
Chris Hill-Scott
8bedcb5af8 Move data transformation into the form
Follows what we’re doing with the folders stuff. Avoids having too many
very straightforward methods on the model. Especially when the data they
need is only used by the form. So it’s better to encapsulate the logic
in the form.
2018-11-13 09:57:17 +00:00
Chris Hill-Scott
c18a38d4f1 Make handling of None values in forms clearer
If the browser posts the value of `<input value='None'>` to the server
it does so as a string.

We want to post a value of `None` (actually JSON `null`) to the API. To
do this we:
- set the value in the form class to `'None'` (ie a string)
- convert to `None` (as a type) afterwards

However seeing `x = 'None'` in code looks a bit like a mistake. So to
make sure it looks deliberate and clear what is happening this commit:
- makes a reusable constant for `'None'`
- adds a comment explaining why it’s a string
2018-11-12 09:04:39 +00:00
Chris Hill-Scott
cdb5b47c4d Post to the API when moving folders and templates
This commit adds logic to:
- take the list of selected folders and templates
- split it into two lists (of folders and templates)
- `POST` that data to the API, to effect the movement of said folders
  and templates

I’ve tried to architect it in such a way that we can easily add more
template ‘operations’ in the future, as we add more forms to the choose
template page.
2018-11-12 08:37:46 +00:00
Chris Hill-Scott
2743216519 Show form elements for templates and folders
This commit adds:
- checkboxes to let you select a template or folder
- radio buttons to let you select where to move those template(s) and/or
  folder(s) to

It only does the `get` part of this work; handling the `post` and
calling API will be done in a subsequent commit.
2018-11-12 08:37:46 +00:00
Alexey Bezhan
622fdfedc9 Merge pull request #2452 from alphagov/create-template-folders
Create template folders
2018-11-08 11:58:39 +00:00
Chris Hill-Scott
c0c0015dc4 Merge pull request #2448 from alphagov/alphabetical-sort-letter-brandings
Make letter brandings easier to find with sorting and filtering
2018-11-07 13:50:05 +00:00
Chris Hill-Scott
514a98f946 Make hex colour code error more helpful
I just got stuck for like a whole minute on this.
2018-11-07 10:49:04 +00:00
Leo Hemsted
1ecf360e7f add template folder form 2018-11-06 13:13:12 +00:00
Leo Hemsted
7cbf5de240 add new template folder
The add new templates page now has option to add template folders.
Tweaked wording of other options and h1 to clarify options since it's
not all about templates any more.

Added api client and stuff for it
2018-11-06 13:13:12 +00:00
Chris Hill-Scott
43988661d6 Sort selected item to the top
When you land on the page it’s good to be able to quickly see what the
currently-set value is, before you change it.

This is unnecessarily hard if the selected item is buried half way down
the page. This commit moves it to the top.
2018-11-06 13:06:48 +00:00
Chris Hill-Scott
c960fef8f8 Always put HM Government at the top of the list
It’s the default, so we should treat it the same way we treat GOV.UK in
the email branding selection.
2018-11-06 13:04:45 +00:00
Chris Hill-Scott
65cc6adabf Sort letter brandings alphabetically
Currently the brandings have non-deterministic sorting, which means
the order changes from page load to page load. This makes it hard to
find the item you’re looking for.

This commit sorts them by the name of the branding, same as for email
brandings.
2018-11-06 13:02:40 +00:00
Chris Hill-Scott
e04b2b5631 Split models to prevent circular imports
This commit is the first step to disentangling the models from the API
clients. With the models in the same folder as the API clients it makes
it hard to import the API clients within the model without getting a
circular import.

After this commit the user API clients still has this problem, but at
least the service API client doesn’t.
2018-10-30 15:01:36 +00:00
Pea Tyczynska
3cdacaaf0a Introduce validation and error handling for validation preview 2018-10-05 15:46:44 +01:00