Commit Graph

9084 Commits

Author SHA1 Message Date
Leo Hemsted
5bbbdc3cd9 fix xss with service letter contact blocks
service contact blocks contain new lines - and jinja2 normally ignores
newlines (as in it keeps them as new lines) - but we need to turn them
into `<br>` tags so that we can show the formatting that the user has
added. We were previously just doing `{{ block | nl2br | safe }}`. nl2br
turns the new lines into `<br>` tags, and then `safe` tells jinja that
it doesn't need to escape the html.

this causes issues if the user adds `<script>alert(1)</script>` to their
contact block (or some other evil xss hack), where that will get let
through due to the safe flag

To solve this, use `Markup(html='escape')` to sanitise any html, and
then convert new lines to <br>.

bump utils

another xss
2020-01-21 17:34:49 +00:00
Leo Hemsted
c57aec8cd5 Merge pull request #3270 from alphagov/bump-python
bump python version
2020-01-21 15:17:30 +00:00
Leo Hemsted
edfcd49861 bump python version
we all run 3.6 locally, we test against 3.6 both locally and on
concourse, and the latest version of openpyxl (required by
pyexcel-xlsx) doesn't support 3.5 anymore
2020-01-21 15:10:43 +00:00
Leo Hemsted
772a47e870 Merge pull request #3269 from alphagov/reqs-bump
bump requirements
2020-01-21 14:55:40 +00:00
Leo Hemsted
9620559a55 bump requirements 2020-01-21 14:47:18 +00:00
David McDonald
8a41b63e23 Merge pull request #3267 from alphagov/bank-hols
Add more bank holiday dates
2020-01-21 10:24:02 +00:00
Chris Hill-Scott
6ff9dac161 Merge pull request #3254 from alphagov/letter-validation-short-messages
Add separate messages for precompiled letters that have failed validation
2020-01-21 10:02:58 +00:00
Chris Hill-Scott
68bc41685c Merge pull request #3266 from alphagov/job-status-not-on-uploads
Don’t assume a job’s status will be present
2020-01-21 10:02:51 +00:00
David McDonald
8d2053216f Add more bank holiday dates 2020-01-20 17:14:54 +00:00
Chris Hill-Scott
0202f73f9a Remove job_status from allowed properties
We can’t guarantee it’s always present, so shouldn’t allow direct access
to it.
2020-01-20 16:47:09 +00:00
Chris Hill-Scott
34f209a08b Fix mixed-up error messages
The too many pages error was being returned when the file couldn’t be
read. This commit corrects the error message, and adds a test to make
sure this case is covered.
2020-01-20 15:54:07 +00:00
Chris Hill-Scott
1fc0f58541 Add test for plural form of error message 2020-01-20 15:50:16 +00:00
Chris Hill-Scott
bc7deebcc7 Split test in two for readability 2020-01-20 15:46:03 +00:00
Chris Hill-Scott
32105b3328 Don’t assume jobs status will be present
The API response for jobs includes a field called `job_status`. The API
response for uploads doesn’t.

The `Job` mode handles uploads and jobs, so it needs to account for the
possibility of the field not being there.
2020-01-20 15:25:47 +00:00
Tom Byers
182c47dfa6 Merge pull request #3265 from alphagov/cookies-update-2nd-attempt
Cookies update 2nd attempt
2020-01-20 14:54:42 +00:00
Tom Byers
62f1c5a88e Fix associated test 2020-01-20 10:05:15 +00:00
Tom Byers
5de29f2389 Fix Google Analytics tracking code 2020-01-20 10:05:15 +00:00
Tom Byers
a67cd65f47 Make Google Analytics cookies expire in 1 year 2020-01-20 10:05:06 +00:00
Tom Byers
1d9c5e5da9 Default the cookie banner to be hidden
It should only be shown if JS is available and the
cookieMessage JS finds consent has not been set.
2020-01-20 10:04:58 +00:00
Tom Byers
1a97c6028c Add event tracking to window.GOVUK.analytics
app/assets/javascripts/errorTracking.js sent
events to `window.ga`.

This extends the API of `window.GOVUK.Analytics`
to include support for sending events so all
calls to `window.ga` can use it instead of direct
access.

This use of `window.ga` was missed from the
initial work on `window.GOVUK.Anaytics`.
2020-01-20 10:04:56 +00:00
karlchillmaid
c8f36683ed Remove lead in line before table 2020-01-20 10:04:18 +00:00
Tom Byers
2d1a51cafb Add captions to tables on cookies page 2020-01-20 10:04:18 +00:00
Tom Byers
c11f6c403a Remove line-break from cookies page paragraph 2020-01-20 10:04:18 +00:00
karlchillmaid
16f3c1ad13 Update description of what the cookies do
Update description of what information the cookies capture
2020-01-20 10:04:18 +00:00
Tom Byers
24f18f914b Change size and layout of cookie banner buttons 2020-01-20 10:04:08 +00:00
Tom Byers
4c532f24af Remove unused argument from cookie_banner macro 2020-01-20 10:04:07 +00:00
Tom Byers
ac13d6a4f4 Make 'Hide' button identify as a link
It looks like a link so its semantics should
identify it as one.

This can effect users of speech recognition
software, in scenarios where they instruct it to
click an element which looks like one thing but
the software can only identify as something else.
2020-01-20 10:04:07 +00:00
karlchillmaid
a7876f4661 Update cookies content 2020-01-20 10:03:54 +00:00
karlchillmaid
24c418bfe6 Change 'we' to 'Notify'
Makes the meaning a bit clearer
2020-01-20 10:03:48 +00:00
karlchillmaid
b1e6841bb7 Replace negative contraction
Replace negative contraction.

GDS style guide: https://www.gov.uk/guidance/style-guide/a-to-z-of-gov-uk-style#contractions
2020-01-20 10:03:47 +00:00
Tom Byers
b17140ac46 Fix test description 2020-01-20 10:03:47 +00:00
Tom Byers
ff2e1dd921 Add hidden text to cookie banner buttons
Visual users get the context from the proximity to
the h2 but we need to provide this for others.

I've tried using `aria-describedby` to link them
to the h2 but this ends up making the h2 text the
button's description in the accessibility tree. In
Voiceover this means you only get that information
as extra context, announced a while after the
label if the VO cursor stays on the button.

We want all the information in the accessible
label so chose this approach instead.
2020-01-20 10:03:47 +00:00
Tom Byers
d37379fc68 Change banner content to just cover analytics
Follows discussions with @quis, @yahoopete and
@karlchillmaid.
2020-01-20 10:03:47 +00:00
Tom Byers
8a0d0a15a8 Hide cookie banner if no-js
Decided in discussions with @quis and @yahoopete
that users without JS available cannot
accept/reject analytics cookies so the banner has
no use.
2020-01-20 10:03:47 +00:00
Tom Byers
3e8ed578d0 Improvements based on frontend feedback
Paired with @aliuk2012 on the implementation and
with a view to making the component generic enough
to be used on digital marketplace apps as well.
These changes came from that session.

They include:
- removal of an unused `data-accept-cookies`
  attribute
- removal of `govuk-!-padding-top-4` class and
  moving of associated styles into component CSS
- swapping out the `aria-label` on the parent
  element for an `aria-describedby` linked to the
  h2 to have one thing labelling the banner region
- removal of unused CSS and any already provided
  by the govuk-button class
- inclusion of @import's for styles attached to
  govuk-body and govuk-button classes
2020-01-20 10:03:36 +00:00
Tom Byers
9a0d522964 Add JS tests for analytics & cookies JS
Includes:
- tests for the analytics interface ported from
  GOVUK Frontend Toolkit
- tests for the cookie banner that appears on all
  pages except the cookies page
- tests for the cookies page JS
- tests for the hasConsentFor function
- adding a deleteCookie helper to remove
  cookies during tests
- polyfill for insertAdjacentText

The last one is because JSDOM doesn't support
insertAdjacentText but our target browsers
do. This polyfill also includes one for
insertAdjacentHTML.
2020-01-20 10:03:36 +00:00
Tom Byers
28140104f1 Fix python tests broken by cookie banner 2020-01-20 10:03:19 +00:00
Tom Byers
ca019d4a0d Fix typo on privacy page 2020-01-20 10:03:19 +00:00
Tom Byers
34b85cae10 Update cookies page
Includes:
- new content
- added option to turn analytics on/off
- non-js version for the on/off switch
- a banner to confirm user's choice was saved,
  shown when they click the save button
- the cookie banner that appears on all other
  pages removed from this page
2020-01-20 10:03:19 +00:00
Tom Byers
1d864943c5 Move code for deleting old cookies into banner JS
Removes the following cookies:
- seen_cookie_message (flags if banner was already
  shown)
- _gid (Google Analytics cookie)
- _ga (Google Analytics cookie)

These were set by default before so potentially
still around for some users.

The code for this now exists as a static method on
the cookieMessage module and is called when the JS
loads for the first time.
2020-01-20 10:03:19 +00:00
Tom Byers
fa7104d6c8 Add new cookie banner code.
Copies HTML and Sass from GOV.UK Pubishing
components cookie-banner with changes to content
and functionality to better suit Notify.

Changes are:
- adds a 'reject' button which the GOV.UK
  code doesn't have
- adds Sass from the GOV.UK Frontend button
  component which the GOV.UK version used so
  is included here
- removed click tracking from cookie banner
2020-01-20 10:03:18 +00:00
Tom Byers
6ef77cfff3 Add new analytics code to frontend build 2020-01-20 10:03:18 +00:00
Tom Byers
181adc9940 On page load, call analytics based on consent 2020-01-20 10:03:18 +00:00
Tom Byers
0ecbff6a8b Add consent tracking to cookie functions
Taken from GOVUK components:

https://github.com/alphagov/govuk_publishing_components/blob/master/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js

Also includes:
- make new cookie functions handle notify domains
- addition of hasConsentFor function to allow easy
  checking of consent for categories of cookie
2020-01-20 10:03:18 +00:00
Tom Byers
a8d6df9b04 Wrap analytics code in GOVUK interface
Wraps our analytics code in a stripped down
version of GOVUK.Analytics to allow us to plug in
the GOVUK code for consent.
2020-01-20 10:03:18 +00:00
Chris Hill-Scott
a5fe50ce72 Merge pull request #3262 from alphagov/rename-model-property
Rename `client` property on `ModelLists`
2020-01-17 11:08:08 +00:00
Chris Hill-Scott
462a3b56a0 Merge pull request #3264 from alphagov/account-for-missing-scheduled_for
Account for missing scheduled for field
2020-01-17 10:12:01 +00:00
Chris Hill-Scott
fa4fd1c896 Account for missing scheduled for field
Jobs have a `scheduled_for` field. Single letter uploads don’t.

At the moment we treat both of them as `Job`s. So the `Job` model needs
to account for when the `scheduled_for` field is missing.
2020-01-17 10:01:39 +00:00
Chris Hill-Scott
67b3619229 Remove redundant redefinition of __init__
At some point we made the __init__ method on the base class accept
`*args` as an argument, so we don’t need to define our own method here.
2020-01-16 16:34:49 +00:00
Chris Hill-Scott
c4818eb7f2 Rename property on ModelLists
The property doesn’t represent the whole client, but just one method on
it. So this commit renames the property to better describe what it is
designed to store.
2020-01-16 16:31:20 +00:00