Commit Graph

184 Commits

Author SHA1 Message Date
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
Pea Tyczynska
d60ab838a8 Edit mobile page allows users to proceed without changing mobile number
Also:
- change formatting of mobile number redact characters

- redirect if session empty

- update a test with new mock after rebase
2019-02-26 11:50:56 +00:00
Pea Tyczynska
94c4151640 Edit user permissions page shows redacted phone number and Change link
Also make plan for story development
2019-02-26 11:50:17 +00:00
Chris Hill-Scott
032cbf9a17 Flag go live requests from DWP
It’s not enough to check that they’ve signed the agreement. We have to
make sure we inform them every time a service wants to go live.
2019-02-19 11:18:50 +00:00
Chris Hill-Scott
ba8d2ff1e3 Don’t let domains have none values 2019-02-12 13:33:13 +00:00
Chris Hill-Scott
0ce4dca799 Don’t allow domains to be none 2019-02-12 13:29:27 +00:00
Katie Smith
f005d7a569 Refactor to split s3_client.py into multiple files
Separated s3_client.py into 3 files - for logos, CSV files and the MOU.
This helps to keep things clearer now that we need to add lots more logo
functions for letters.
2019-02-06 17:26:58 +00:00
Chris Hill-Scott
f2c7be57a4 Stop referring to service.postage
All templates have postage now and we will be getting rid of
`service.postage`.
2019-02-06 14:54:58 +00:00
Chris Hill-Scott
cd70355db8 Display postage everywhere we display a letter
To avoid the problem of having confusing defaults, the postage is now
set explicitly on every template.

Putting the postage ‘inside’ the letter template makes the interaction
for changing it consistent with how other parts of the template are
added.

Plus everyone loves skeumorphism.
2019-02-06 14:37:16 +00:00
Pea Tyczynska
bb1e9d2a0f Add validation-failed status to FAILURE_STATUSES in admin utils 2019-01-10 15:54:31 +00:00
Pea Tyczynska
dcc590ec96 Cancelled notifications do not show as failures on dashboard stats
Also update tests after we no longer show cancelled letters
2019-01-10 15:27:04 +00:00
Chris Hill-Scott
a8b916b57f Refactor gov user check into a decorator
We quite often use it in the same way as `@user_has_permissions`.
2018-12-12 13:42:26 +00:00
Pea Tyczynska
1858ee93fd Notifications CSV Report now also shows sender email address 2018-12-07 11:20:20 +00:00
Katie Smith
429a23934d Display cancelled letters show as failed
In the long term, we don't want to show cancelled letters. But for now,
this changes cancelled letters to display in the same way that letters
with a status of permanent-failure, since we are currently giving
letters that we want to cancel the status of permanent failure.
2018-12-05 11:03:59 +00:00
Katie Smith
088d6ee4b0 Content changes for notification pages
This commit adds content pages for the notifications pages, particularly
the letter pages, which will make things clearer now that we will soon be allowing
letters to be cancelled.

The main changes are:
* The confirmation banner for letters sent from a CSV file now states when
printing will start.
* We state the CSV file that notifications were sent from on the
notifications page
* The notification page for letters shows when printing starts (today,
tomorrow, or that date that the letter was printed)
2018-12-03 10:42:47 +00:00
Alexey Bezhan
ef4921d2f9 Merge pull request #2534 from alphagov/final_countdown
'Data available for {}' message on job page accounts for flexible data retention
2018-11-29 15:49:27 +00:00
Chris Hill-Scott
bc6b9c7af7 Use named arguments for clearer string formatting
Helps when the string is long.

Also helps disambiguate between the CDN domain used for the logos and
those for CSS/JS.
2018-11-29 11:56:01 +00:00
Pea Tyczynska
9d8e602ac8 time_left considers flexible data retention periods
Also update tests
2018-11-26 15:15:06 +00:00
Katie Smith
c48f54aba4 Bump notifications-utils to 30.7.0
Bumped the notifications-utils version. The `gmt_timezones` function in
this repo and the `utc_string_to_aware_gmt_datetime` in
notifications-utils are the same, so have updated the code to always use
the version in utils.
2018-11-26 14:43:42 +00:00
Leo Hemsted
32f39475d2 remove dupe of get_letter_timings
it was moved from admin to utils a while ago
2018-09-28 15:02:32 +01:00
Chris Hill-Scott
c2ef522986 Make task list read better for screen readers
This duplicates how the task list pattern is coded in the GOV.UK
Prototype kit[1]. It adds ARIA attributes and the use of a
semantically-meaningful element (`<strong>`) to give more information to
screen reader users.

1. https://govuk-prototype-kit.herokuapp.com/docs/templates/task-list
2018-09-25 10:31:40 +01:00
Alexey Bezhan
5198009550 Merge pull request #2300 from alphagov/submit-returned-letters
Add a platform admin page to submit returned letter references
2018-09-07 15:06:24 +01:00
Alexey Bezhan
b75681dfbc Add a platform admin page to submit returned letter references
A platform admin form accepts a list of references (one per line)
received from DVLA and sends them to the API to update notification
statuses.

References we get from DVLA start with `NOTIFY00\d`, which isn't
part of the reference we store in the database, so we remove them
before sending the data to the API.

The new `returned-letter` status should be treated as `delivered`
for now until we decide a way to display returned letters to users.
2018-09-07 11:13:01 +01:00
Chris Hill-Scott
20e71499f0 List who sent a message in CSV download
This is useful if you have lots of people sending messages and want to
report on who’s doing what.

Needs the API updating to return `created_by_name` in its response.
2018-09-06 14:52:31 +01:00
Chris Hill-Scott
47c9b71fa8 Add canonical domain info to agreement class
Because we alias domains (eg `foo.gsi.gov.uk` to `foo.gov.uk`, or where
a local council has multiple domains) it could be hard to look up a
brand (which has one domain field).

Therefore we need a way of getting the canonical domain from a user’s
email address, which we can later use to look up their branding.
2018-09-05 10:32:43 +01:00
Chris Hill-Scott
45eb16b4db Check text message sender before going live
We often check that a service has an appropriate text message sender as
a condition of them going live. We don’t mention this anywhere.

The services for whom GOVUK is definitely not an appropriate sender are
those in local government. As we have more of these teams starting to
use Notify, we should streamline the process by making this check
automated.

This commit adds that check, for teams who:
- have text message templates
- have self-declared as NHS or local government
2018-08-29 11:29:44 +01:00
Chris Hill-Scott
5a52eafb84 Fix ‘Back’ link from first step of fix one off
If you skip past the templates page (because you don’t have the edit
permission) but then click back you end up in a loop which redirects you
to the page you’re already on.

This commit makes sure that you’re sent back a step further, so you
don’t get stuck in that loop.
2018-08-10 09:16:18 +01:00
Chris Hill-Scott
92a258dc41 Use model for template previews 2018-07-30 14:56:36 +01:00
Chris Hill-Scott
660fadbce7 Make the guessing a bit more sophisticated
Things we’ve noticed from looking at real data that we could handle in a
smarter way:
- removing numbers (there might be a tom.smith2@dept.gov.uk if tom.smith
  is already taken)
- removing middle initials (again, these tend to be used for
  disambiguation and aren’t included when we ask people for their names)
- ignoring email addresses which only have someone’s initial, not their
  first name (because we can’t make a decent guess in this case)
2018-07-11 13:31:38 +01:00
Chris Hill-Scott
3683f99c3b Guess people’s names when they’re invited
Most people’s names, especially in government are in the format
firstname.lastname@department.gov.uk. This means that you can pretty
reliably guess that their name is ‘Firstname Lastname’.

When users are invited to Notify we know their email address already.

So this commit pre-populates the registration form based on this guess.

This is a nice little detail, but it should also stop the browser
pre-filling the name field with someone’s email address (which I think
happens because the browser assumes a registration form will have an
email field).
2018-07-11 10:35:25 +01:00
Chris Hill-Scott
ed9444b436 Fix org info in branding requests with known orgs
This wasn’t looking quite right in the case where an organisation is in
our list of domains.
2018-07-10 17:18:50 +01:00