Commit Graph

470 Commits

Author SHA1 Message Date
Chris Hill-Scott
68191a93ef Don’t show postage choice for international letters
International letters don’t have a choice of postage. Under the hood
they are either `europe` or `rest-of-world`.

So, for letters that we detect are international, this commit:
- removes the radios buttons that give users the choice of postage
- passes through either `europe` or `rest-of-world` to the API,
  depending on what address we find in the letter

This will cause the API to 500 until it can accept `europe` or
`rest-of-world` as postage types, but this is probably OK because it’s
only our services that have international letters switched on at the
moment.
2020-05-21 14:20:18 +01:00
Chris Hill-Scott
3378dfe258 Remove letter sending route without file_id
All instances of the app will be posting to the URL with the `file_id`
parameter now, so we can remove the old route without the ID now.
2020-05-21 14:20:18 +01:00
Tom Byers
f0f461f5c9 Revert "Change checkboxes to GOVUK frontend" 2020-05-14 16:59:34 +01:00
Tom Byers
49ec2d77bb Update all single field checkboxes
Includes adding some code to govukCheckboxesField
to add a single boolean-like option by default, if
there are no choices added.
2020-05-13 17:37:44 +01:00
Tom Byers
33d8171675 Update templates page
Includes:
- changes to the govukCheckboxesField class
  to allow params to be extended at render time
- updates to templates and folders CSS
2020-05-13 17:37:42 +01:00
Tom Byers
0291fbc1cb Update manage folder page 2020-05-13 17:36:40 +01:00
Tom Byers
e030d7d3a1 Update permissions page 2020-05-13 17:36:40 +01:00
Tom Byers
a99ca640e3 Split common checkbox methods off into mixin 2020-05-13 17:36:40 +01:00
Tom Byers
b5f3d1e6e6 Add govukCheckboxField for single checkboxes
Single checkboxes are distinct because:
- they don't need to be wrapped in a `<fieldset>`
- they are a subclass of BooleanField so their
  data is either True or False
2020-05-13 17:36:38 +01:00
Tom Byers
691034ef85 Fix nested checkboxes with single top-level node
Nested checkboxes with a single top-level node
will only have one item in their `items` list.
This is because the other choices are children of
that list item.

This means we need to check the `choices`
attribute, which lists all the checkboxes, to see
if they should be marked as a group (by being
wrapped in a `<fieldset>`) or not.
2020-05-13 16:25:17 +01:00
Tom Byers
efc4aff4fe Add govukCollapsibleNestedCheckboxesField
Includes:
1. changes to make NestedFieldMixin work
  with new fields and CSS for nested checkboxes
2. adds custom version of GOVUK checkboxes
  component to allow us to:
  - add classes to elements currently inaccessible
  - wrap the checkboxes in a list
  - add child checkboxes to each checkbox (making
    tree structures possible through recursion

Change 2. should be pushed upstream to the GOVUK
Design System as a proposal for changes to the
GOVUK Checkboxes component.
2020-05-13 16:20:10 +01:00
Tom Byers
06027b447c Add mixin & field to make collapsible checkboxes
Allows checkboxes to be collapsed so they take up
less space in the page. The collapsed state
includes a live summary tracking which of them are
selected.

Includes changes to the JS for collapsible
checkboxes to make it work with the GOVUK
Checkboxes component HTML.
2020-05-13 16:16:21 +01:00
Tom Byers
012d5767d7 Add govukCheckboxesField
govukCheckboxesField subclasses
SelectMultipleField and overwrites how it renders
HTML to let us use the GOVUK Checkboxes component
while retaining all the functionality of WTForms
fields.

Based on work on github.com/richardjpope/recourse:

https://github.com/richardjpope/recourse/blob/master/recourse/forms.py#L6
2020-05-13 16:13:57 +01:00
Chris Hill-Scott
0ef076f59e Merge pull request #3416 from alphagov/validate-3-lines-csv
Allow all the new address goodness in spreadsheets
2020-05-01 15:37:08 +01:00
Chris Hill-Scott
06108de0f7 Allow international addresses in spreadsheets
For services with permission, they can now put international addresses
into their spreadsheets without getting a postcode error.

This also means they can start using address line 7 instead of postcode,
since it doesn’t make sense to put a country in a field called
‘postcode’. But this will be undocumented to start with, because we’re
not giving any real users the permission.

It does now mean that the number of possible placeholders (7 + postcode)
is greater than the number of allowed placeholders (7), so we have to
account for that in the one-off address flow where we’re populating the
placeholders automatically. We’re sticking with 6 + postcode here for
backwards compatibility.
2020-04-29 16:19:57 +01:00
Chris Hill-Scott
65bb72ef2f Bump WTForms to 2.3.1
This involves three changes which broke our code.

To validate email addresses, the optional dependency `email-validator`
must be installed<sup>1</sup>. But since we don’t use WTForms’ email
validation, we shouldn’t need to subclass it – it can just be its own
self contained thing. Then we don’t need to add the extra dependency.

When rendering textareas, and extra `\r\n` is inserted at the beginning
<sup>2</sup>. Browsers will strip this when displaying the textbox and
submitting the form, but some of our tests need updating to account for
this.

The error message for when you don’t choose an option from some radio
buttons has now changed. Rather than just accepting WTForms’ new
message, this commit makes the error messages like the examples from
the Design System<sup>3</sup>. By default it will say ‘Select an
option’, but by passing in an extra parameter (`thing`) it can be
customised to be more specific, for example ‘Select a type of
organisation’.

***

1. https://github.com/wtforms/wtforms/pull/429
2. https://github.com/wtforms/wtforms/issues/238
3. https://design-system.service.gov.uk/components/radios/#error-messages
2020-04-23 12:57:10 +01:00
David McDonald
f91aba212d Merge pull request #3419 from alphagov/sms-sender-length
Reduce min sender length from 4 to 3
2020-04-21 14:53:52 +01:00
David McDonald
9f557dd086 Reduce min sender length from 4 to 3
This is now supported at the network and aggregator level
2020-04-21 12:51:54 +01:00
Chris Hill-Scott
b0cf36e1c7 Allow spaces and dashes in the two factor code
I noticed when using the dication software that saying ‘one two three
four five’ got dictated as `123 45`. This tripped the validation,
because the space character isn’t a digit.

So this commit normalises out spaces (and other spacing characters like
dashes and underscores) before validating the code and sending it to the
API.

I can also imagine that some people might like to space out the code to
make it easier to transcribe (like you might do with a credit card
number).
2020-04-17 16:16:52 +01:00
Chris Hill-Scott
6c7e6fa64e Remove the code to handle optional address placeholders
Optional address placeholders aren’t a thing for one-off letters any
more, so we can tidy up the code a bit by removing the parts of the flow
that are accounting for them.
2020-04-14 15:19:29 +01:00
Chris Hill-Scott
c646c16067 Add postcode validation check for one-off letters
We’re doing this everywhere else now, so this completes the story.

It uses the same regex as elsewhere and the error messaging is
consistent (but not uniform) with the other places.
2020-04-07 09:08:51 +01:00
Chris Hill-Scott
26f702ebce Refactor to use PostalAddress helper from utils
Since we’re doing normalisation and line-count-checking of addresses in
multiple places it makes sense for that code to be shared. Which is
what happened here:
https://github.com/alphagov/notifications-utils/pull/713

This commit refactors the admin code to make use of the new utils code.

Note about placeholders:
- they now go into the session as `address_line_1` instead of `address
  line 1` because this is the format the API uses, so should be
  considered canonical
- they are now fetched from the session in a way that isn’t sensitive
  to case or underscores (using the `Columns` class)
- the API doesn’t care about case or underscores vs spaces in
  placeholder names because it’s checking an instance of `Template` to
  see if all the required placeholders are present (see
  401c8e41d6/app/notifications/process_notifications.py (L40))
2020-04-07 09:00:55 +01:00
Chris Hill-Scott
1fe3f1871e Allow underscores in SMS senders 2020-04-02 15:57:46 +01:00
Leo Hemsted
c4d839d4f5 input letter address data in a single block
rather than in multiple placeholders - this is the first step towards
making postcodes non-required, which is the first step towards
international letters.

they still populate address_line_# and postcode fields under the hood -
to keep validation working the same, the last line always goes into
`postcode`.

the form normalises whitespace, removes extra new lines, and enforces
that you have between three and seven lines.

if the letter repeats address placeholders further down (eg "Dear
((address_line_1))"), then it'll fill those in as well. It'll still
prompt you to fill them in, but they'll be pre-filled.
2020-03-30 19:29:26 +01:00
Chris Hill-Scott
30a3418473 Refactor so constants are used everywhere 2020-03-24 17:48:13 +00:00
Chris Hill-Scott
11cdf58256 Use the same form for problems and questions 2020-03-24 17:48:11 +00:00
Chris Hill-Scott
61ab9661fb Direct members of the public somewhere more useful
We can’t give advice to members of the public, but increasingly we’re
seeing them try to use our support form to ask.

It would be better for them if we can direct them straight to somewhere
more useful, before they have the chance to raise a support ticket.

This commit replaces the report a problem/ask a question triaging for
users who aren’t signed in. It’s not possible for non-signed-in users to
raise an priority 1 ticket, so we never need to triage the tickets in
this way.

Instead we can triage people based on whether they work in the public
sector or not. If they do then we send them on to the feedback form. If
not then they go to a new page which contains some useful links. We’ve
chosen these links based on some analysis of the support tickets we’ve
received recently[1]

1. https://docs.google.com/spreadsheets/d/1uBQn-ZnCYfz6ltFaUKZpytgvBF0-MeshCLZ1cD74R0c/edit?usp=sharing
2020-03-24 17:48:11 +00:00
David McDonald
9a3e53f57d Mark field as optional
As suggested by the design system
2020-03-23 11:36:06 +00:00
David McDonald
d7385da0df Require email address for all support tickets
We are seeing little benefit of allowing users to not put in their email
address. This will mean that you must provide it for feedback, not just
problems with the site.

There could maybe be some more refactoring of the support templates as
this is now very similar to the report a problem page but this is a
quick fix so haven't gone too in depth.
2020-03-23 11:21:52 +00:00
Leo Hemsted
2d8d2d712a move invite error handler to top level
ensure we catch org errors as well as regular errors
2020-03-06 13:20:31 +00:00
Pea Tyczynska
44519fcf8e Do not allow to upload SVG logos with embedded raster images in them
Those are for example png or jpg images. They do not render properly.
2020-03-04 15:35:12 +00:00
Pea M. Tyczynska
fdff9d3b83 Ensure gov.uk branding only available for emails and not for letters
Also align and statements
2020-01-23 16:34:58 +00:00
Pea M. Tyczynska
cc61e87701 Parametrized options label for the branding request form
Co-Authored-By: Chris Hill-Scott <me@quis.cc>
2020-01-21 16:47:42 +00:00
Pea Tyczynska
02cb6c9c38 Create a letter branding request flow to match email branding request
Test if service settings links to branding request page for letters

Parametrize all branding tests so they also work for letter branding
2020-01-21 16:47:14 +00:00
Chris Hill-Scott
5233ee4bd9 Add a form to set priority of top 2 providers
Their priority should always add up to 100%. Currently we have to ensure
this by hand. Adding this form means there’s no way to not set their
combined priorities to 100%. And it’s a bit more of an intuitive UI than
two textboxes on separate pages.
2019-12-11 10:17:45 +00:00
Pea Tyczynska
21e6d994b9 Validate service and organisation name 2019-11-20 13:31:01 +00:00
David McDonald
4ca4cef1b3 Merge pull request #3144 from alphagov/choose-postage
Choose postage
2019-11-05 10:14:40 +00:00
David McDonald
9ba1dbfffa Do not show postage stamp for letter preview 2019-11-01 10:47:42 +00:00
David McDonald
fdf74572b9 Add radio button and convert from to WTForm 2019-11-01 10:47:42 +00:00
Chris Hill-Scott
fcc84ac514 Do extra code style checks with flake8-bugbear
Flake8 Bugbear checks for some extra things that aren’t code style
errors, but are likely to introduce bugs or unexpected behaviour. A
good example is having mutable default function arguments, which get
shared between every call to the function and therefore mutating a value
in one place can unexpectedly cause it to change in another.

This commit enables all the extra warnings provided by Flake8 Bugbear,
except for the line length one (because we already lint for that
separately).

It disables:
- _B003: Assigning to os.environ_ because I don’t really understand this
- _B306: BaseException.message is removed in Python 3_ because I think
  our exceptions have a custom structure that means the `.message`
  attribute is still present
2019-11-01 10:43:01 +00:00
Katie Smith
3b3f74bbf0 Use the new error messages when uploading a letter
We now use the pattern of showing a box at the top of the page with the
error. The error message has a heading and can have additional details.
Error messages and the invalid pages get stored in the S3 metadata.
2019-10-21 08:37:55 +01:00
Chris Hill-Scott
7f033efc28 Fix email branding request page with only textbox
If there aren’t a range of options (normally presented as radio buttons)
to show the user on the email branding request page then we just show
the textbox. But we were still doing form validation on the radio
buttons, even though the user couldn’t see them to click them. This
stopped the user from being able to submit the form.

This commit fixes the problem by, in this specific case, pre-ticking the
‘Something else’ radio button.
2019-10-09 16:42:30 +01:00
karlchillmaid
a2455abda4 Replace can't with cannot 2019-09-23 13:20:24 +01:00
Chris Hill-Scott
56772533e6 Replace negative contraction with Cannot
In accordance with style guide
2019-09-18 14:21:25 +01:00
Chris Hill-Scott
20f857753a Use constants for organisation type
This reduces the chances of making a typo, because doing so will raise
an exception rather than fail silently.
2019-09-16 11:33:50 +01:00
Chris Hill-Scott
afcdedf598 Allow elaboration when ‘something else’ is chosen
Letting people input a bit of free text should reduce the amount of back
and forth we have to do over support tickets when setting up someone’s
branding.

If something else is the only option then we don’t show the radio button
at all and have just the free text input on the page (not behind a
progressive disclosure).
2019-09-16 11:18:22 +01:00
Chris Hill-Scott
6d0d10e8de Only show relevant choices of email branding
Users who work in local government can’t have GOV.UK branding on their
emails. And only those working for Companies House (for example) can
request the Companies House branding.

This commit adds:
- new choices of email branding, which offer the name of the branding,
  rather than the style
- logic to filter this list to only the applicable options, based on
  what we know about the user, service and organisation

This is a change from the previous approach which put the onus on users
to figure out the style of branding they wanted, when we might already
know that a lot of the options weren’t available to them, or would be
inconsistent with the branding of other services in their organisation.
2019-09-16 11:03:52 +01:00
Katie Smith
c577416866 Add letter upload form which redirects to blank preview page
Added a form to upload a single letter. Currently this only uses the
form to validate that a file is submitted and that the file is a PDF. If
either of these validations fail, the form will display an error.
Otherwise, we redirect to a new preview page which just has the filename
as the heading for now.
2019-09-12 09:54:36 +01:00
Chris Hill-Scott
8b8893ed1d Let NHS Trusts and CCGs choose own organisation
All we do via support is ask which organisation they work for and
manually assign their service to it. This commit makes that process self
service.

We think we have all the trusts and clinical commissioning groups
loaded into the database now.

This will make the go live process smoother for these teams.
2019-09-06 16:26:51 +01:00
Chris Hill-Scott
e0ab43f988 Let GPs nominate service name
Most GP practice services are named after the practice, which is the
organisation.

So rather than make people re-type the name of their organisation (and
potentially make a typo) let’s just let them say ‘yes, that’s the name
of my organisation’.
2019-09-05 15:01:12 +01:00