mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-31 19:58:46 -04:00
Reverts the new postage constraints
Reverts https://github.com/alphagov/notifications-api/pull/2843 and https://github.com/alphagov/notifications-api/pull/2848
This commit is contained in:
@@ -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', 'europe', 'rest-of-world')
|
||||
postage is not null and postage in ('first', 'second')
|
||||
ELSE
|
||||
postage is null
|
||||
END
|
||||
@@ -1353,13 +1353,10 @@ DVLA_RESPONSE_STATUS_SENT = 'Sent'
|
||||
|
||||
FIRST_CLASS = 'first'
|
||||
SECOND_CLASS = 'second'
|
||||
EUROPE = 'europe'
|
||||
REST_OF_WORLD = 'rest-of-world'
|
||||
POSTAGE_TYPES = [FIRST_CLASS, SECOND_CLASS]
|
||||
RESOLVE_POSTAGE_FOR_FILE_NAME = {
|
||||
FIRST_CLASS: 1,
|
||||
SECOND_CLASS: 2,
|
||||
EUROPE: 'E',
|
||||
REST_OF_WORLD: 'N',
|
||||
SECOND_CLASS: 2
|
||||
}
|
||||
|
||||
|
||||
@@ -1436,7 +1433,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', 'europe', 'rest-of-world')
|
||||
postage is not null and postage in ('first', 'second')
|
||||
ELSE
|
||||
postage is null
|
||||
END
|
||||
@@ -1701,6 +1698,13 @@ 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)
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ def validate_schema_email_address(instance):
|
||||
@format_checker.checks('postage', raises=ValidationError)
|
||||
def validate_schema_postage(instance):
|
||||
if isinstance(instance, str):
|
||||
if instance not in ["first", "second", "europe", "rest-of-world"]:
|
||||
raise ValidationError("invalid. It must be first, second, europe or rest-of-world.")
|
||||
if instance not in ["first", "second"]:
|
||||
raise ValidationError("invalid. It must be either first or second.")
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user