Commit Graph

543 Commits

Author SHA1 Message Date
Pea Tyczynska
e22e7245fe Use sanitised pdfs for sending and handle invalid pdfs, details below:
- pass new, sanitised pdf for sending
- move invalid pdfs to a newly created bucket
- set status fro notifications that failed pdf validation to a new status validation-failed
- adjust existing tests
2018-10-16 17:30:35 +01:00
Katie Smith
52095c9c8c Add filename to dvla_organisation table
Added a filename column to the dvla_organisation table and populated it
with the filenames that are currently hard-coded in template-preview.
The filenames for letter logos are going to be stored in the database,
instead of in template-preview.
2018-10-15 10:37:34 +01:00
Chris Hill-Scott
8f9ee7f7ad Add letter org for Brighton and Hove 2018-10-12 10:36:41 +01:00
Katie Smith
f41e0f05ec Make postage column part of ft_billing primary key
Now that the postage column is populated and there are no null values,
it can be added to the composite primary key of ft_billing.
2018-09-28 16:19:49 +01:00
Katie Smith
0936060f5d Add postage column to ft_billing
Added a new varchar column, postage, to ft_billing. This is nullable and
not part of the composite primary key for now, but this will change
later.
2018-09-28 13:52:10 +01:00
Katie Smith
45e714e694 Update first class letter rate start dates
We want to bring the start dates for first class letter rates forward by
a month so that we don't see billing errors when sending first class letters now.
(The feature will still go live at the planned time - this is to let us test things
beforehand.)
2018-09-28 10:25:44 +01:00
Leo Hemsted
2b354eb5df separate notification postage constraint into three separate commits
we had an issue where the notification postage constraint command ran
into a deadlock, after trying to acquire two exclusive access locks on
large frequently modified/read tables.

To avoid this happening, we've had to split the upgrade script into
three - one script to apply the not-valid constraint to notifications
table, one for notification_history, and a third to validate the two
constraints.

Note: The first two scripts acquire exclusive access locks, but the
third only needs a row by row lock.

since this involves changing the exsiting alembic upgrades, if you've
upgraded your db you'll need to run the following three commands to
revert your database to a previous good state.

```
alter table notifications drop constraint chk_notifications_postage_null;
alter table notification_history drop constraint chk_notification_history_postage_null;
update alembic_version set version_num = '0229_new_letter_rates';
```
2018-09-27 15:20:28 +01:00
Leo Hemsted
3739c573ea fix null check in constraint
There are two fun quirks of postgres/sql that we need to work around:
* any `x = y` where x or y is NULL returns NULL, rather than false.
* check constraints accept NULL or true values as good.

so, the check `postage in ('first', 'second')` returns `null` rather
than `false` when postage is null itself. This surprisingly passes the
check constraint. To get around this, we have to add an explicit not
null check as well.
2018-09-25 16:10:26 +01:00
Leo Hemsted
17612e5446 add postage constraint to notification history
A not valid constraint only checks against new rows, not existing rows.
We can call VALIDATE CONSTRAINT against this new constraint to check
the old rows (which we know are good, having run the command from
74961781). Adding a normal constraint acquires an ACCESS EXCLUSIVE
lock, but validate constraint only needs a SHARE UPDATE EXCLUSIVE lock.

see 9d4b8961 and 0a50993f for more information on marking constraints
as not valid.
2018-09-25 16:10:16 +01:00
Pea Tyczynska
ea3144c3fd Add downgrade steps to new rates migration, add end_date to old rates
and refactor migration statements for security good practice
2018-09-25 15:10:16 +01:00
Pea Tyczynska
08fec8f928 Fix tests - update number fo letter rates in test 2018-09-25 15:10:16 +01:00
Pea Tyczynska
86533c2366 Do not update the rate that doesn't change 2018-09-25 15:10:16 +01:00
Pea Tyczynska
0c0166922c Update migration number and get rid of explicit UTC zoning therein 2018-09-25 15:10:16 +01:00
Pea Tyczynska
b3191dbc2a Filter letter rates by post_class in get_rate
Also adjust existing tests.
2018-09-25 15:10:15 +01:00
Pea Tyczynska
8b410e8876 Add new letter rates from 1st of October 2018 2018-09-25 15:10:15 +01:00
Leo Hemsted
918e4b390f add postage to notification + noti_history
if it's a letter notification, postage must equal "first" or "second",
else it must equal null
2018-09-19 16:32:58 +01:00
Rebecca Law
5f73dfdbe9 Added constraints to services.postage: not nullable and can only containt "first" or "second" 2018-09-18 17:41:25 +01:00
Rebecca Law
1c0892888f Change the name of letter_class to postage, this will match the domain language used in the documentation.
Updated the tests to answer review comments.
2018-09-18 15:22:08 +01:00
Rebecca Law
efb618e956 Fix merge conflicts for the db migration file.
Update test_services_dao to stop using fixtures. This is a massive change. The only real change in the file is to check for the letter_class.
2018-09-17 15:45:29 +01:00
Rebecca Law
79815b4f8a In order to support sending letters by first class we need a way to know how the service wants us to send the letter.
To start with this will be an attribute on the service, at the time the notification is created it will look at Service.letter_class to decide what class to use for the letter.

This PR adds Service.letter class as a nullable column.
Updated the create_service and update_service method to default the value to second.

Subsequent PRs will add the check constraint to ensure we only get first or second in the letter_class column and make that column nullable.
This can't be done all at once because it will cause an error if someone inserts or updates a service during the deploy.
2018-09-17 11:27:43 +01:00
Chris Hill-Scott
244e91021d Add two new letter logos 2018-09-14 13:58:50 +01:00
Alexey Bezhan
0dcf04def9 Add notification status for returned letters
We need to update letter notifications with a new status when DVLA
gives us a list of references for returned letters.

This adds the new status to the models and the DB.

DVLA call this 'returned mail', so I'm using it as the status name
since it seems less ambiguous than 'returned'.
2018-09-04 16:55:22 +01:00
Chris Hill-Scott
5d5047fb13 Add unique constraint to email branding domains
Does two things:

1. Revert "Revert "Add unique constraint to email branding domain""

This reverts commit af9cb30ef3.

2. Don’t allow empty string in email branding domain

Columns with multiple `null`s can have a uniqueness constraint. Columns
with multiple empty string values are not considered unique.

This commit:
- removes any duplicate empty string values
- casts empty strings to null string any time these columns are updated

---

Squashed into this single commits because these two things are not
atomic as individual commits.
2018-09-04 11:10:46 +01:00
Chris Hill-Scott
af9cb30ef3 Revert "Add unique constraint to email branding domain" 2018-09-04 10:55:49 +01:00
Chris Hill-Scott
f095fa1ddf Add unique constraint to email branding domain
Brandings with a domain set should be considered canonical. It doesn’t
make sense to have the same domain set on multiple different email
brands – you can’t tell which one to use.
2018-09-04 09:46:50 +01:00
Chris Hill-Scott
834ad73304 Drop service branding column
We’re not using this column any more, so let’s clean up after ourselves.
2018-08-31 15:56:25 +01:00
Chris Hill-Scott
0c47d41977 Remove govuk from possible brands
‘GOV.UK’ doesn’t make sense as a type of brand. It only made sense as
a type of branding that a service had.

Since we’ve:
- deprecated the service branding column
- made sure it’s not used as a value in the email branding table

we can remove this value from the table of possible brand types.
2018-08-30 16:36:35 +01:00
Chris Hill-Scott
337496c5bc Deprecate service branding column
We want to drop this column. First we have to stop using it anywhere.

Needs to be made nullable so we can stop writing to it.
2018-08-30 16:05:37 +01:00
Chris Hill-Scott
11225b7149 Make branding type non-nullable
We’ve already removed all the `null` values, and made it impossible to
add new brandings with a `null` brand type.

Making it a database constraint just gives us extra safety.
2018-08-29 12:46:21 +01:00
Chris Hill-Scott
0107cdcfde Set branding_type to org if it’s none
Same as a0deef06e2 but with `is null` not
`= null` 🤦🏻
2018-08-28 17:24:14 +01:00
Chris Hill-Scott
a71ce9fb54 Add NHS logo for letters
Matches: https://github.com/alphagov/notifications-template-preview/pull/192
2018-08-28 16:56:42 +01:00
Chris Hill-Scott
a0deef06e2 Set branding_type to org if it’s none
So later we can:
- make it non-nullable later
- remove `govuk` as an option

This is mostly for people’s local databases, the manual work here has
been done on production already.
2018-08-28 16:22:42 +01:00
Rebecca Law
a960d2fb1d Remove db columns 2018-08-24 16:09:17 +01:00
Rebecca Law
25c5e0ceb8 Need to do the data migration after removing the columns in the code. 2018-08-24 15:51:28 +01:00
Rebecca Law
45632293b2 Remove new colour columns 2018-08-24 13:53:04 +01:00
Rebecca Law
6c5e60f0a9 Fix merge conflicts 2018-08-23 15:04:44 +01:00
Rebecca Law
4fe1e6bb66 Merge branch 'master' into add-brand-type-to-email-branding 2018-08-23 15:02:55 +01:00
Rebecca Law
f80cd508ac Fix name typo 2018-08-23 14:43:41 +01:00
Rebecca Law
3816010c72 Add brand_type to EmailBranding.
It makes more sense to put the brand_type with EmailBranding rather than in Service.
Next step is to add the new type to the form in admin app.
2018-08-23 13:53:05 +01:00
Chris Hill-Scott
a950425882 Add letter logo for Pension Wise 2018-08-23 13:38:56 +01:00
Rebecca Law
640a400165 DB update script - missing from last commit 2018-08-16 17:10:02 +01:00
Chris Hill-Scott
e0570c1773 Remove caseworking permission
What became ‘caseworking view’ is now available to all services.
2018-08-10 09:09:18 +01:00
Rebecca Law
c30e58eaad Instead of deleting the data in the name field just copy it to the text field.
The admin app still needs to use the name column.
Add the text field to the post data schemas.
If the text is not in the post data, then populate it with the data in the name field.
This should make the migration to text easier, and will work until we are able to update the admin app.
2018-08-02 15:55:45 +01:00
Pea Tyczynska
4345771547 Update migration file version number for email_branding update 2018-07-31 18:01:58 +01:00
Pea Tyczynska
f69bc50985 Move data back before dropping the column for downgrade 2018-07-31 17:58:19 +01:00
Pea Tyczynska
c5792f4d79 Migration file for email_branding fields update 2018-07-31 17:58:19 +01:00
Pea Tyczynska
cf20cea81c Fix migration version numbering 2018-07-31 16:44:21 +01:00
Pea (Malgorzata Tyczynska)
ea28b65871 Merge pull request #1999 from alphagov/drop_monthly_billing_table
Drop monthly billing table
2018-07-31 16:35:48 +01:00
Rebecca Law
cc36209564 Fix file name for migration script 2018-07-31 14:00:18 +01:00
Rebecca Law
7378232353 Added migration script 2018-07-31 13:54:37 +01:00