Commit Graph

4738 Commits

Author SHA1 Message Date
Chris Hill-Scott
abdbaf6cbb Merge pull request #1696 from alphagov/preview-any-row
Add URLs for previewing all rows of a spreadsheet
2017-12-20 12:07:19 +00:00
Chris Hill-Scott
eb395db2d6 Fix error when file has header rows but no data
Previously the error was saying ‘It needs at least one row of data, and
columns called None’.
2017-12-20 11:59:51 +00:00
Chris Hill-Scott
5f5dd3ac41 Rewrite check for row existence as conditional
Because exceptions can be expensive performance wise (see:
https://docs.python.org/3/faq/design.html#how-fast-are-exceptions).

Since we’re counting the number of rows anyway this doesn’t introduce
any performance overhead there. And I think it’s equally readable/same
number of lines of code.
2017-12-20 11:48:30 +00:00
Chris Hill-Scott
c3e2bce98b Add URLs for previewing all rows of a spreadsheet
We’ve heard from some users, especially those sending letters, that
they’d like to check that a spreadsheet they’ve uploaded has populated
the template correctly.

My reckon is that seeing just one row of the spreadsheet populate the
template isn’t enough to give people confidence that everything’s
working properly. So this commit is the first step towards being able
to preview an arbitrary row of a template, by extending the URL
structure to optionally accept a row number for pages or files (ie PNG)
that preview successfully uploaded spreadsheets.

What this commit doesn’t do is link to these pages; that will come as
part of a subsequent commit.
2017-12-20 11:15:38 +00:00
Chris Hill-Scott
587e18d2ef Lookup index, rather than iterating
Since instances of `Recipients` are now iterable we can just look up the
first row by index, rather than having to hit the rows property as a
generator.

There is a chance that there won’t be a first row, if the file has 1 or
fewer columns. So we still need to handle a possible exception (albeit
it a different one to before).
2017-12-20 11:15:37 +00:00
Chris Hill-Scott
3e5deeffdb Split successful upload test into two
Easier to test the individual aspects of what’s going on here if they’re
two separate tests, one hitting the initial `POST`, and one hitting the
page that they’re subsequently redirected to.
2017-12-20 11:15:37 +00:00
Chris Hill-Scott
71368301f7 Make test use new fixture
The `client_request` fixture means the tests take fewer lines of code
and also checks some extra things (eg page titles matching <h1>s).

Changing it in this commit, independently of functional changes to this
test.
2017-12-20 11:15:37 +00:00
Chris Hill-Scott
5bac021493 Remove unused variable
This variable isn’t used by our Jinja templates. Presumably it was
from the time before instances of `Template` were responsible for
showing who the email/text message was being sent to.
2017-12-20 11:15:36 +00:00
Chris Hill-Scott
acdaad966c Merge pull request #1715 from alphagov/quis-patch-1
Fix page titles on callbacks documentation
2017-12-18 14:40:12 +00:00
Chris Hill-Scott
3a67555d4d Update callbacks.html 2017-12-18 14:14:36 +00:00
Chris Hill-Scott
3df3c61279 Fix page titles on callbacks documentation
This page is no longer just about inbound.
2017-12-18 14:13:40 +00:00
Chris Hill-Scott
821ba2acd2 Merge pull request #1714 from alphagov/mmo
Add Marine Management Organisation as email domain
2017-12-18 12:43:38 +00:00
Chris Hill-Scott
08c007d998 Add Marine Management Organisation as email domain
Seems like sometimes they use a Defra email address, sometimes their
own .org.uk one.
2017-12-18 11:52:56 +00:00
Chris Hill-Scott
05c7be8950 Merge pull request #1709 from alphagov/remove-error-stuff
Remove error-handling code from OK page
2017-12-15 15:00:59 +00:00
Chris Hill-Scott
fa3885d47d Remove error-handling code from OK page
`ok.html` is only used when there’s a spreadsheet which doesn’t have
any errors in it.
2017-12-14 18:06:25 +00:00
Chris Hill-Scott
ef55feba36 Merge pull request #1707 from alphagov/120-121
120-121 for Analyse School Performance
2017-12-14 11:29:06 +00:00
Pete Herlihy
2378854cc8 120-121 for Analyse School Performance 2017-12-14 11:20:16 +00:00
Chris Hill-Scott
81e4f27efc Merge pull request #1701 from alphagov/strip-whitespace
Strip whitespace before validating any form
2017-12-14 11:18:48 +00:00
Chris Hill-Scott
a8829cd154 Make whitespace stripping work for whitelists too
It’s a bit hacky, but it fixes a potential issue for users.

Code adapted from:
2c34f678ab
2017-12-14 11:06:55 +00:00
Chris Hill-Scott
d0d230f119 Remove existing whitespace stripping code
Since we’re doing this globally, we don’t need to handle it in a custom
way for the sign in form (and it’s much nicer encapsulated like this).

Also added some more extensive tests in this commit.
2017-12-14 11:06:55 +00:00
Chris Hill-Scott
70badae575 Strip whitespace before validating any form
We’ve had whitespace-in-emails problems on:
- register form
- sign in form
- send one off form

We should just handle whitespace gracefully, by ignoring it. Makes sense
to do this at a global level because there might be other places it’s
causing problems that we don’t know about.

The only place that users _might_ be relying on leading/trailing spaces
(and we have no way of knowing this) is in passwords or tokens. So this
filter ignores any instances of `PasswordField`.

Adapted from @pcraig3’s work on Digital Marketplace:
- 4b06f5cfb7
- e761c1ce65
2017-12-14 11:06:55 +00:00
Chris Hill-Scott
9fcc906f26 Merge pull request #1708 from alphagov/callbacks-wording
Tweaks to callback pages
2017-12-14 11:04:12 +00:00
Chris Hill-Scott
3f01da05c7 Fix order of callbacks
Delivery comes before inbound. The order of the URLs was jumbled in two
places:
- in the view function
- in the Jinja template

So as the user saw it the URLs were in the right order, because the
double jumbling cancelled itself out. But it made the code _really_
confusing to read.
2017-12-13 11:58:21 +00:00
Chris Hill-Scott
f02ec30979 Make table labels match titles of callback pages
This makes it consistent from page to page, and match the wording that
Thom came up with.
2017-12-13 11:56:26 +00:00
Chris Hill-Scott
87aee243b6 Merge pull request #1702 from alphagov/hr
Add undocumented support for <hr>s in emails
2017-12-13 10:41:16 +00:00
Chris Hill-Scott
378c066b33 Merge branch 'master' into hr 2017-12-13 10:20:37 +00:00
Katie Smith
02d8dc3f1d Merge pull request #1705 from alphagov/fix-edit-letter-contact-block-🐞
Fix bug when editing letter contact block from letter template page
2017-12-13 10:13:43 +00:00
Pete Herlihy
3eaeefbd37 Merge branch 'master' into hr 2017-12-12 16:38:08 +00:00
Katie Smith
87f5a9e124 Fix bug when editing letter contact block from letter template page
When viewing a letter template, there is a button to edit the letter
contact block. This should take the user to the page to edit the letter
contact block, but if a service has not set any letter contact blocks, the
button was returning a 404 error.

The code has now been changed so that if the service has no letter contact
blocks the edit button will link to the page to add a letter contact
block.

Pivotal story: https://www.pivotaltracker.com/story/show/152881444
2017-12-12 16:38:07 +00:00
Pete Herlihy
7ee1cc56ae Merge pull request #1704 from alphagov/119-120
119-120 for Home Office Tier 4 Premium
2017-12-12 16:34:38 +00:00
Pete Herlihy
13569bb7f8 119-120 for Home Office Tier 4 Premium 2017-12-12 15:06:53 +00:00
Venus Bailey
de23e9cb77 Merge pull request #1700 from alphagov/vb-callback-admin
Allow service to set callback url for notifications
2017-12-12 10:49:13 +00:00
venusbb
6f0ce3b33d rewrite one of the obsolete test 2017-12-11 17:17:40 +00:00
Chris Hill-Scott
5b435c5457 Add undocumented support for <hr>s in emails
Implements:
- [x] https://github.com/alphagov/notifications-utils/pull/275/files
2017-12-11 16:36:03 +00:00
venusbb
3377efb267 Merge branch 'master' of https://github.com/alphagov/notifications-admin into vb-callback-admin
Some content change
Refractor api_integration to api_keys to reduce git difference.
2017-12-11 13:43:29 +00:00
Chris Hill-Scott
f156373e9a Merge pull request #1685 from alphagov/comma-error
Update error message about commas in placeholders
2017-12-11 11:56:45 +00:00
venusbb
deda4e1d57 Merged 2017-12-11 11:44:29 +00:00
venusbb
482309af3b fixed empty callback dict problem 2017-12-11 11:40:38 +00:00
chrisw
9c0d2c2a39 refactor of api callbacks admin work 2017-12-11 11:37:33 +00:00
chrisw
cd3d8edccd Allowed custom attributes to be added to textbox component 2017-12-11 11:37:26 +00:00
chrisw
df383b5c0f renamed api_keys file 2017-12-11 11:37:26 +00:00
chrisw
76117c148c Allow service to set callback url for notifications 2017-12-11 11:37:26 +00:00
Chris Hill-Scott
eef66b70de Reword because ‘inbetween’ isn’t a word 2017-12-11 11:19:33 +00:00
Chris Hill-Scott
242a216c1b Update error message about commas in placeholders
We call the yellow things ‘double brackets’ on the frontend, not fields
or placeholders. This error message was a bit out of date.

Also refactored it to use the `Field` class; this code was probably
written before `Field` was factored out of `Template`.
2017-12-11 11:19:33 +00:00
Chris Hill-Scott
72dd0b369f Merge pull request #1698 from alphagov/pyup-update-pyexcel-xls-0.5.4-to-0.5.5
Update pyexcel-xls to 0.5.5
2017-12-11 11:17:58 +00:00
pyup-bot
34aca4de5b Update pyexcel-xls from 0.5.4 to 0.5.5 2017-12-11 10:41:20 +00:00
Pete Herlihy
58b999ec60 Merge pull request #1699 from alphagov/117-119
117-119 for Cash Service MK and HMCTS Small Claims Mediation
2017-12-11 10:38:51 +00:00
Pete Herlihy
79912166d7 117-119 for Cash Service MK and HMCTS Small Claims Mediation
50 - 51 orgs too
2017-12-11 10:25:23 +00:00
Chris Hill-Scott
8cc478f731 Merge pull request #1691 from alphagov/strip-spaces-sign-in
Strip spaces from email addresses when signing in
2017-12-08 16:21:26 +00:00
Chris Hill-Scott
bef8e8887b Strip spaces from email addresses when signing in
If you copy and paste an email address into the sign in box, there’s a
chance you’ll also copy some leading or trailing spaces. This is
especially likely to happen if you’re doing this while using your
computer upside down.

If this happens, it never even gets as far as looking up the user,
because the form validation doesn’t consider a string with a leading
space to be a valid email address.

This commit makes sure that accidental spaces are handled, by removing
them before doing any validation or hitting the API to look up the user.
2017-12-08 16:17:45 +00:00