Commit Graph

214 Commits

Author SHA1 Message Date
Chris Hill-Scott
f5649d72c9 Explain 3 required address columns
Our rules about address columns are relaxing, so that none of them are
mandatory any more. Instead you just need any 3 of the 7 to make a valid
address.

This commit updates our error messaging to reflect that.
2020-04-27 16:47:49 +01:00
Katie Smith
13650b7d4b Update error messages for letters that are too long
To specify the number of sheets as well as pages in case this is not
clear.
2020-04-09 11:03:07 +01:00
Chris Hill-Scott
54d7c6fcbd Get ready to error for precompiled letters with bad addresses
Template preview is going to start returning these errors; we need to be
ready to handle them.
2020-04-07 09:09:03 +01:00
Pea Tyczynska
86ab0a6a0f Add missing test cases for precompiled validation messages 2020-04-02 13:39:40 +01:00
Pea Tyczynska
0a7fa1f799 Update content for postcode valdiation handling for precompiled 2020-04-02 11:45:57 +01:00
Pea Tyczynska
5036511803 Handle postcode validation 2020-04-02 11:23:17 +01:00
Chris Hill-Scott
03f2368deb Use the correct bucket for storing contact lists
We don’t want to muddy them up with the normal CSV uploads.

I’ve tried to reuse the existing S3 code where possible because it’s
well tested.

Buckets have already been created.
2020-03-16 13:07:39 +00:00
Tom Byers
e6767c4d01 Make links in validation summaries red 2020-02-25 15:32:31 +00:00
Tom Byers
9f2e1498fc Update links missed in previous work
Includes those in:
- the static 5xx error page
- validation messaging
- guidance page about trial mode
- links used in tests

Issues raised in https://github.com/alphagov/notifications-admin/pull/3303#issuecomment-589572715
2020-02-25 10:52:03 +00:00
Tom Byers
5b306dde4d Revert "Convert all links to govuk frontend" 2020-02-24 11:56:38 +00:00
Tom Byers
f90b6b46e6 Make links in validation summaries red 2020-02-21 15:50:28 +00:00
Tom Byers
1513cfa9e6 Update links missed in previous work
Includes those in:
- the static 5xx error page
- validation messaging
- guidance page about trial mode
- links used in tests

Issues raised in https://github.com/alphagov/notifications-admin/pull/3303#issuecomment-589572715
2020-02-21 13:59:04 +00:00
Pea Tyczynska
e413798b4d Change email_access_validated_at formatting to be more in line with other dates on User model 2020-02-17 11:34:25 +00:00
Pea Tyczynska
7d460fe483 Move date-checking logic to utils and unit test it 2020-02-17 11:34:25 +00:00
Katie Smith
f425fe75cf Update link in error messages for uploaded letters 2020-02-13 16:14:11 +00:00
karlchillmaid
10e0c39001 Add reference for letter_spec_guidance 2020-02-13 15:53:03 +00:00
karlchillmaid
8a0a9666d7 Update links 2020-02-13 15:50:22 +00:00
karlchillmaid
fadf29c9b0 Fix API validation error summary links 2020-02-13 15:08:40 +00:00
karlchillmaid
90462d7c71 Update link to Letter specification guidance 2020-02-13 14:58:53 +00:00
Leo Hemsted
4e1fcfbff1 handle invalid upload errors correctly
previously it assumed that invalid_pages would always exist, however it
might be `None` if the error isn't on a specific page. Errors on
specific pages include a page not being A4 or content being outside the
boundary. Errors not on specific pages include the file not being a pdf,
or containing too many pages
2020-01-27 15:11:37 +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
3762daad84 Add a redirect for the letter specification
This way we have a URL we can give people that always points to the
latest version of the spec.

And it makes our code more Flask-idiomatic to be using `url_for` to be
generating a URL, rather than passing around a constant.
2020-01-15 11:54:14 +00:00
Chris Hill-Scott
540945539b Add some summaries of letter validation errors
We show letter validation errors in two places:

1. In response to a user uploading a PDF
   Here we use the error banner pattern because the problem is as a
   direct consequence of a user’s action, and is blocking them from
   continuing.

2. Once a PDF provided through the API has been validated
   We use a less prominent pattern of red text with no border because
   the message is reporting on something that’s already happened, and
   which wasn’t a direct consequence of the user clicking something

Because the context and patterns used are different we need slightly
different content in each of these situations. Previously we tried to
reuse the same content to make the code cleaner and less repetitive. But
ultimately a clear interface trumps clear code.
2020-01-14 13:34:18 +00:00
Chris Hill-Scott
a186d0eeff Don’t repeat the letter spec URL in the code
We change this URL fairly frequently because we bump the version number.
Let’s make it easier to change by only defining it once.
2020-01-14 13:32:13 +00:00
Chris Hill-Scott
72abd89fe0 Fix indentation and trailing commas
This will make the diffs introducing substative changes easier to read.
Consistent indenting and always having trailing commas on lists and
dictionaries makes for smaller diffs.
2020-01-14 13:31:29 +00:00
Rebecca Law
f7b3f9b06a - Remove the trailing comma from the first line of the "to" field
- Add client_reference to the activity CSV report
- Show the recipient on the CSV report the same way as the view activity page.
2020-01-10 16:00:40 +00:00
Rebecca Law
70276cb526 Added a new error message when the letter is mising an address block.
Before deploying a change to template-preview to return a validation error for letters that are missing the address block, we need to add the new erorr message to admin.

Some content changes have been made to other messages.
The format of the message has changed.
2020-01-10 14:42:56 +00:00
Pea Tyczynska
9e0c8167ee Content changes to error messages 2019-12-03 13:36:54 +00:00
Pea Tyczynska
64b35ba337 Add addtional test cases for row errors 2019-12-03 13:36:53 +00:00
Pea Tyczynska
f265dde8ab Validate CSVs against rows with empty messages 2019-12-03 13:36:41 +00:00
Pea Tyczynska
678e0bed81 Show users more detailed validation failed mesage on notification page
Show valdiation failed messages on letter notifications in red text,
not in the banner like we do on Uploads and Validation checker pages.
This is because it is a different step in the journey: the user
has already sent the notification and styling needs to be in line
with other places where user is checking the notification she already
has sent.
2019-11-07 11:10:27 +00:00
Chris Hill-Scott
59b4d60c91 Munge stuff into a consistent event data type
We store our audit history in two ways:

  1. A list of versions of a service
  2. A list of events to do with API keys

In the future there could be auditing data which we want to display that
is stored in other formats (for example the event table).

This commit adds some objects which wrap around the different types of
auditing data, and expose a consistent interface to them. This
architecture will let us:
- write clean code in the presentation layer to display these events on
  a page
- add more types of events in the future by subclassing the `Event` data
  type, without having to rewrite anything in the presentation layer
2019-10-23 13:02:11 +01:00
Katie Smith
8f7a05200d Add function to map template-preview errors to user-friendly errors
Template preview now returns a short string as it's error message plus
a list of invalid pages.
2019-10-21 08:35:04 +01:00
Pea Tyczynska
2ed1e382b4 Move letter length check to utils repo so template-preview can use it, too
Update requirements
2019-10-10 14:25:19 +01:00
Pea Tyczynska
12ec2870af Move letter too long banner message over from utils, also refactor 2019-10-09 16:03:47 +01:00
Chris Hill-Scott
40e020d40d Remove expand_emails argument from get_template
It isn’t used for anything now.
2019-09-02 17:04:53 +01:00
Chris Hill-Scott
17b8c0194b Update utils and remove expanded argument
This argument was removed in https://github.com/alphagov/notifications-utils/pull/643
2019-09-02 17:04:53 +01:00
Leo Hemsted
1d67c82f0f utils bump
also dont use splitlines on csv data, there might be quoted newlines we dont want to split on
2019-08-02 14:34:05 +01:00
Pea Tyczynska
4a679a6583 Letter job can't be cancelled if already printed
Non-cancellable letter statuses mean that it's too late to cancel a job
2019-07-04 14:44:21 +01:00
Chris Hill-Scott
b620b677d3 Have permissions decorators check user signed in
Rather than force us to write the decorators in a specific order let’s
just have one decorator call the other. This should make fewer lines of
code, and fewer annoying test failures. It also means that the same way
of raising a `401` (through the `current_app` method) is used
everywhere.
2019-07-03 09:54:35 +01:00
Chris Hill-Scott
34f0c83690 Don’t bother with YAML syntax
Since this file doesn’t have any complicated data types, plain text with
one line per domain is fine.
2019-06-03 13:21:29 +01:00
Chris Hill-Scott
8835486d4e Look in organisation for whitelisted domains
At the moment we have to update a YAML file and deploy the change to get
a new domain whitelisted.

We already have a thing for adding new domains – the organisation stuff.

This commit extends the validation to look in the `domains` table on the
API if it can’t find anything in the YAML whitelist.

This has the advantage of:
- not having to deploy code to whitelist a new domain
- forcing us to create new organisations as they come along, so that
  users’ services automatically get allocated to the organisation once
  their domain is whitelisted
2019-06-03 11:41:13 +01:00
Chris Hill-Scott
20e774ca33 Use keyword argument for explicitness 2019-05-08 10:17:20 +01:00
Chris Hill-Scott
55d4810c4b Don’t convert Excel reports to CSV before output
Converting Python data to CSV makes every field a string. This means
that in the report we return to the user every field will be a string,
even if it’s come from an `int` type in Python. This is because the CSV
‘standard’ doesn’t support any kind of typing.

Excel does support types for fields, so we can make our reports more
useful by preserving these types. This is particularly relevant in the
report we generate for performance platform, which needs the `count`
column to be a number type.

This commit adds extra code paths to the `Spreadsheet` class which mean
that it can be instantiated from either CSV data or a list of Python
data. Previously we were converting the Python data to CSV as an
intermediate step, before instantiating the class.
2019-05-07 16:07:23 +01:00
Chris Hill-Scott
5879df5c03 Move as_dict property to its own method
This helps declutter the init method, and is one less thing to create in
memory when it’s not needed.
2019-05-07 11:30:33 +01:00
Chris Hill-Scott
3c38a7be05 Provide Performance Platform report as Excel file
This is the format we need to upload it in, so this means not having to
manually re-save it as Excel.
2019-05-03 15:40:53 +01:00
Pea Tyczynska
b0a8c5edf6 Get live services csv report 2019-05-01 15:59:50 +01:00
Chris Hill-Scott
3212915a51 Simplifying code for checking email domains
Since this code isn’t trying to inherit from the code that also looked
up domain names in `domains.yml` it can go back to being a lot simpler.

This code is thoroughly tested already here:
a249382e69/tests/app/main/test_validators.py (L74-L155)
2019-04-12 15:23:08 +01:00
Chris Hill-Scott
9d99c78c3a Remove code that reads domains.yml
Since we’ve removed calls to this code from the rest of the app, it can
safely be removed now.
2019-04-12 15:23:08 +01:00
Katie Smith
c675925fd1 Upgrade pyexcel-io, which also upgrades Werkzeug
Upgraded pyexcel-io from 0.5.14 to 0.5.16. This change causes Werkzeug
to be upgraded from 0.14.1 to 0.15.1 which requires some changes:

* ProxyFix now needs to be imported from a different location
* The status code of RequestRedirect has changed from 301 to 308. Since
status code 308 is not currently supported on Internet Explorer with
Windows 7 and 8.1, this subclasses RequestRedirect to keep the status
code of 301.

changelog: https://werkzeug.palletsprojects.com/en/0.15.x/changes/#version-0-15-0
2019-03-22 14:18:44 +00:00