Commit Graph

130 Commits

Author SHA1 Message Date
Chris Hill-Scott
d1cd74daa8 Update utils with to make letters unclickable
Brings in:
- [ ] https://github.com/alphagov/notifications-utils/pull/159

Means:
- renaming a bunch of things
- removing any CSS that targeted the link, and making it target the
  containing element too
2017-05-03 12:20:45 +01:00
Chris Hill-Scott
d62fbcb4cb Update utils version 2017-04-27 13:52:03 +01:00
Chris Hill-Scott
36db0ad598 Show all pages of a letter in the app
In research we’ve seen two problems with the click-to-see-PDF thing:

- it’s not very intuitive that the letter is clickable, or what you
  can expect when clicking the letter
- people get lost of stuck in the PDF view because it opens in the same
  tab, or they open it in a new tab and then get find their way back, or
  …

So this commit changes the show template page to show the entire
contents of the letter, same as we do for emails and text messages.

Right now it only does it on the view template page. I think we’ll have
to work out a way of showing some kind of truncated version on the _Send
yourself a test_ and _Preview_ pages. But that’s for later.
2017-04-20 15:57:43 +01:00
Leo Hemsted
6d5f90eea2 Merge branch 'master' into letters-from-a-service 2017-04-11 17:11:51 +01:00
Leo Hemsted
a6318f2674 remove pdf/png code from admin app entirely
while PDFs work on paas, they only do that because it turns out the
python buildpack happens to have imagemagick preinstalled - if that
ever changes then it'd break. so move those to the template preview
service. This also means we can get rid of weazyprint and wand
dependencies
2017-04-10 17:45:22 +01:00
Rebecca Law
c9a519dac7 Update the version of notification-utils. 2017-04-10 15:41:57 +01:00
Rebecca Law
4d49fabcdd Merge branch 'master' into refactor-s3-upload
Conflicts:
	requirements.txt
2017-04-10 11:44:56 +01:00
Rebecca Law
80a82cfdab Update notifications-utils to the latest version 2017-04-10 11:43:45 +01:00
Chris Hill-Scott
f5b4d72f8f Bump utils
Didn’t bump it enough versions as part of https://github.com/alphagov/notifications-admin/pull/1215/files

😔
2017-04-06 17:05:55 +01:00
Rebecca Law
faad2f5a09 correct version number in requirements. 2017-04-06 10:26:31 +01:00
Rebecca Law
b2088762c3 Update requirements with notifications-utils version 2017-04-06 10:24:23 +01:00
Chris Hill-Scott
e34d981dda Fix no. of column headers on breaking change page
The breaking change page wasn’t properly accounting for the fact that
letter recipients span multiple columns – it was assuming they’d only
take up one column like they do for email and SMS.

This commit fixes:
- the number of column headers (A, B, C, …) to be correct
- the count of columns (you will need X columns in your file) to be
  correct

It then parameterises the test to look at a case where a recipient is
in one column (email) and multiple columns (letter).
2017-04-06 10:22:36 +01:00
Chris Hill-Scott
35e12a02a0 Bump Boto version
Our deploys have stopped working. It’s complaining with an `ImportError`
somewhere in Boto:

```
017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR Traceback (most recent call last):
2017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR   File “/home/vcap/app/.heroku/python/bin/aws”, line 19, in <module>
2017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR     import awscli.clidriver
2017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR   File “/app/.heroku/python/lib/python3.5/site-packages/awscli/clidriver.py”, line 33, in <module>
2017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR     from awscli.help import ProviderHelpCommand
2017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR   File “/app/.heroku/python/lib/python3.5/site-packages/awscli/help.py”, line 27, in <module>
2017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR     from awscli.clidocs import ProviderDocumentEventHandler
2017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR   File “/app/.heroku/python/lib/python3.5/site-packages/awscli/clidocs.py”, line 18, in <module>
2017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR     from botocore.utils import is_json_value_header
2017-04-04T10:46:26.17+0100 [APP/PROC/WEB/0]ERR ImportError: cannot import name ‘is_json_value_header’
2017-04-04T10:46:26.20+0100 [APP/PROC/WEB/0]OUT Terminating application process with pid
```

Our version of Boto is a year old. Upgrading it to the latest version
seems like a good idea.

Not a breaking version number change. Changelog here:
https://github.com/boto/boto3/blob/develop/CHANGELOG.rst

Complete changes:
https://github.com/boto/boto3/compare/1.3.0...1.4.4
2017-04-04 11:05:04 +01:00
Chris Hill-Scott
b0a995beb2 Handle lists as CSV field values
Brings in:
- [ ] https://github.com/alphagov/notifications-utils/pull/128

This means that `RecipientCSV` will sometimes return the value of a cell
in a spreadsheet as a `list`, not a `string`. So we need to handle that,
rather than putting a Python representation (`['one', 'two', 'three']`)
on the page.

This commit handles it by putting a bulleted list on the page instead.

This breaks our model of showing the spreadsheet as it appears in Excel
or whatever, because we’re showing the aggregation of the columns into a
list. However:
- this is the easier thing to do for now
- it might actually be more usable because it keeps the table narrower
2017-04-04 09:35:15 +01:00
Leo Hemsted
85404f20db bump utils to 13.10.0
pass in the base URL - if not set in the environment this is set to
localhost, but on paas we can pull this out of vcap_services so that
letters render properly on paas
2017-03-27 17:59:06 +01:00
Chris Hill-Scott
c5d418e165 Bump utils to bring in letter layout tweaks
Includes
- [x] https://github.com/alphagov/notifications-utils/pull/127
- [ ] https://github.com/alphagov/notifications-utils/pull/129
2017-03-24 11:35:27 +00:00
Chris Hill-Scott
77b41aa851 Pin six to a version that’s more likely to work
Everything is fine and happy locally and on Jenkins.

Getting a `cannot import name viewkeys` error on AWS.

Based on some Googling, it’s possible that this will fix it.
2017-03-15 13:13:14 +00:00
Chris Hill-Scott
3a8fe23a2d Update utils to get latest version of bleach
Implements:
- [ ] https://github.com/alphagov/notifications-utils/pull/126
2017-03-14 11:29:37 +00:00
Chris Hill-Scott
35cd6a740f Bump utils to fix type size of contact block
Brings in:
- [ ] https://github.com/alphagov/notifications-utils/pull/125

Changes:
- https://github.com/alphagov/notifications-utils/compare/13.9.1...contact-block-type-size
2017-03-03 17:33:15 +00:00
Chris Hill-Scott
795f8f658e Bump utils to improve letters and validation
Brings in:
- [x] https://github.com/alphagov/notifications-utils/pull/120
- [x] https://github.com/alphagov/notifications-utils/pull/121
- [x] https://github.com/alphagov/notifications-utils/pull/122
- [x] https://github.com/alphagov/notifications-utils/pull/123
- [ ] https://github.com/alphagov/notifications-utils/pull/124

Changes:
https://github.com/alphagov/notifications-utils/compare/13.8.0...check-missing-first
2017-03-01 13:43:21 +00:00
Leo Hemsted
efd976e32e downgrade non-gsm chars in SMS previews
bump utils to 13.8.0

we still save the content as the user intended, and they'll still see
that content in the text field if they go to edit the template, but
the SMS previews will appear as they will on a user's phone
2017-02-20 12:03:16 +00:00
Chris Hill-Scott
7a3fb4d2a9 Bump utils to turn off Markdown links 2017-02-16 21:18:27 +00:00
bandesz
b148a0a6a0 Add awslogs logging for PaaS 2017-02-16 14:19:37 +00:00
Chris Hill-Scott
4d3a935a1b Bump utils to turn on Markdown links 2017-02-08 17:01:51 +00:00
Chris Hill-Scott
df6c899796 Fix XSS vulnarability with emails
Rolling this into the same PR because it’s just a version bump.

Brings in:
- [ ] https://github.com/alphagov/notifications-utils/pull/113
2017-02-06 12:33:32 +00:00
Chris Hill-Scott
8bb15e7a58 Handle partial letter addresses more gracefully
Brings in:
- [x] https://github.com/alphagov/notifications-utils/pull/108

Specifically, see these tests for detail of what happens when someone
only fills in some of the required/not required lines of an address:
9e6cb14a5c (diff-e5050dea996611c8bdf32cfe6e8214cdR264)
2017-02-06 12:33:32 +00:00
Chris Hill-Scott
fe02567e63 Fix display of placeholders with incomplete CSV
Brings in:
- [ ] https://github.com/alphagov/notifications-utils/pull/111
2017-01-31 13:58:23 +00:00
Chris Hill-Scott
597c6da857 Sanitize HTML in templates using utils
We can no longer trust that the content of templates stored in the
database is safe.

Utils now has code to sanitise the content of templates.

This commit:
- updates utils to bring this code in
- modifies some integration tests to make sure everything is working
  (there are more extensive unit tests in utils)
2017-01-19 16:34:34 +00:00
Chris Hill-Scott
e73629be2e Bump utils
Brings in:
- [ ] https://github.com/alphagov/notifications-utils/pull/107
2017-01-18 14:22:30 +00:00
Leo Hemsted
88b848a4a3 bump utils to 13.1.0
brings in changes to allow logging json to sdout on cloudfoundry boxes
2017-01-17 11:44:42 +00:00
bandesz
10950bb8a6 Run on Paas 2017-01-17 11:44:42 +00:00
Chris Hill-Scott
559433c5d2 Add remaining endpoints for PDFs and PNGs
Right now we can show what a letter template looks like as a PDF or PNG.

This commit completes the work so this is also possible when:

- showing a template with the placeholders replaced
- showing any version of a template

Also removes dependency on `Exception().message`, which was deprecated
in Python 2.6. See
97f82d565f
for full details.
2017-01-04 15:45:59 +00:00
Chris Hill-Scott
b99279afad Add link to Bleach bugtracker
Explains why we’re using forked version of Weasyprint
2016-12-20 13:43:53 +00:00
Chris Hill-Scott
f5f3d8acae Update patched Weasyprint fork to alphagov hosted
Better than it being on my personal Github account.
2016-12-20 13:17:01 +00:00
Chris Hill-Scott
3713bad569 Include content count bug fix
Includes:
- [x] https://github.com/alphagov/notifications-utils/pull/102
2016-12-14 15:51:03 +00:00
Chris Hill-Scott
922a27e74b Use more sensible version number for html5lib
html5lib version numbers look like 0.999, 0.9999, etc.

This was making people unhappy, so they’ve added version numbers like
1.0b1, 1.0b2, etc which map to the numbers with lots of nines.

The equivalent version for 0.9999999 (7 nines) is 1.0b8 😐
2016-12-14 15:02:54 +00:00
Chris Hill-Scott
dc63de0f4e Incorporate breaking utils changes
Brings in:
- [ ] https://github.com/alphagov/notifications-utils/pull/94
2016-12-14 14:32:07 +00:00
Chris Hill-Scott
ae356fc741 Use PDF link renderer to preview letters
Depends on and implements:
- [x] https://github.com/alphagov/notifications-utils/pull/84
- [ ] https://github.com/alphagov/notifications-utils/pull/86
2016-12-13 10:34:19 +00:00
Chris Hill-Scott
43296469d6 Add endpoint for generating an image of a letter
The PDF preview is all good, but it’s hard, finickeity and feels dirty
to embed a PDF in a web page. It’s a more natural thing to embed an
image in a web page.

So this commit adds another endpoint to return an image of a letter
template. It generates this image from the PDF preview, so the stack
looks like:

1. `template.png` (generated in admin)
2. `template.pdf` (generated in admin)
3. HTML preview (generated by a `Renderer` in utils)
4. `Template` instance
5. serialised template from API
6. Template stored in database

The library used to convert the PDF to an image is Wand[1], which binds
to ImageMagick underneath. So in order to get this working locally on a
Mac you will probably need to do:
`brew install imagemagick ghostscript cairo pango`.

To get it working on Ubuntu/EC2 is an exercise left to the reader…

1. http://docs.wand-py.org/en/0.4.4/
2016-12-13 10:34:18 +00:00
Chris Hill-Scott
4f72cc20ef Use patched version of WeasyPrint
Reasons here: 99718c2caf
2016-12-13 10:34:18 +00:00
Chris Hill-Scott
18d11aa013 Move code for rendering messages/templates → utils
Utils is better structured to handle the logic of what thing to show
for what template type, especially now that what we show for different
template types in different contexts has diverged significantly.

See https://github.com/alphagov/notifications-utils/commit/6b39c1a for
an example of this code moving into utils

Depends on and implements:
https://github.com/alphagov/notifications-utils/pull/84

The main reason for doing this is to get Paul’s fix for the misaligned
CSV columns: https://github.com/alphagov/notifications-utils/pull/87
2016-12-05 12:11:54 +00:00
Martyn Inglis
c7549d552e Bumped version of utils 2016-12-01 13:13:48 +00:00
Martyn Inglis
0c9d188ef5 Bumped utils version 2016-12-01 11:34:18 +00:00
Martyn Inglis
655e6892ad Bumps client version 2016-11-30 17:01:02 +00:00
Rebecca Law
d2f943ed2e Update python client to version 3.0.0 from 1.3.0 2016-11-22 15:04:40 +00:00
Chris Hill-Scott
69ad5fe156 Handle multi-column recipients
Implements https://github.com/alphagov/notifications-utils/pull/81

Handles addresses as multiple columns:
- in ‘Send yourself a test’
- in example CSV files
- in validating that a CSV file has recipients (eg at least an ‘address
  line 1’ and ‘postcode’ column)
- when showing the contents of a CSV file

As few UI changes as possible, once we have the thing working end-to-end
we can think about how the UI might need to work differently.
2016-11-14 14:53:06 +00:00
Chris Hill-Scott
c3b580b645 Update utils 2016-11-14 14:29:13 +00:00
Chris Hill-Scott
2c6ab4756f Bump utils
Includes:
- [ ] https://github.com/alphagov/notifications-utils/pull/75
2016-10-31 09:19:53 +00:00
Leo Hemsted
bd07aa97a7 remove monotonic as a dependency
"On Python 3.3 or newer, monotonic will be an alias of time.monotonic from the standard library"
2016-10-19 10:39:22 +01:00
Chris Hill-Scott
a32dcbf8e3 Error if a CSV file contains more than 50,000 rows
We want to limit the number of rows someone can have in a job, because
it gets too slow to process the file otherwise.

This should be the first error that a user sees, because we can’t work
out if there are other errors until they’ve got the file down to a
processable size.

This also means adding a message to say that the file can’t be displayed
if it doesn’t contain any processed rows.

***

https://www.pivotaltracker.com/story/show/129830161
2016-10-16 10:55:19 +01:00