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.
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
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).
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
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
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
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.
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
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)
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.
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 😐
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/
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.
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