Merge pull request #2747 from alphagov/update-postage-constraint

Update postage db constraints for international letters
This commit is contained in:
Katie Smith
2020-04-08 08:23:43 +01:00
committed by GitHub
7 changed files with 160 additions and 15 deletions

View File

@@ -903,7 +903,7 @@ class TemplateBase(db.Model):
postage = db.Column(db.String, nullable=True)
CheckConstraint("""
CASE WHEN template_type = 'letter' THEN
postage is not null and postage in ('first', 'second')
postage is not null and postage in ('first', 'second', 'europe', 'rest-of-world')
ELSE
postage is null
END
@@ -1353,10 +1353,13 @@ DVLA_RESPONSE_STATUS_SENT = 'Sent'
FIRST_CLASS = 'first'
SECOND_CLASS = 'second'
POSTAGE_TYPES = [FIRST_CLASS, SECOND_CLASS]
EUROPE = 'europe'
REST_OF_WORLD = 'rest-of-world'
RESOLVE_POSTAGE_FOR_FILE_NAME = {
FIRST_CLASS: 1,
SECOND_CLASS: 2
SECOND_CLASS: 2,
EUROPE: 'E',
REST_OF_WORLD: 'N',
}
@@ -1433,7 +1436,7 @@ class Notification(db.Model):
postage = db.Column(db.String, nullable=True)
CheckConstraint("""
CASE WHEN notification_type = 'letter' THEN
postage is not null and postage in ('first', 'second')
postage is not null and postage in ('first', 'second', 'europe', 'rest-of-world')
ELSE
postage is null
END
@@ -1698,13 +1701,6 @@ class NotificationHistory(db.Model, HistoryModel):
created_by_id = db.Column(UUID(as_uuid=True), nullable=True)
postage = db.Column(db.String, nullable=True)
CheckConstraint("""
CASE WHEN notification_type = 'letter' THEN
postage is not null and postage in ('first', 'second')
ELSE
postage is null
END
""")
document_download_count = db.Column(db.Integer, nullable=True)