Even more cleanup.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-02-21 12:35:18 -05:00
parent 43a8b6539f
commit afc1de61f6
12 changed files with 94 additions and 85 deletions

View File

@@ -9,7 +9,7 @@ post_create_email_branding_schema = {
"name": {"type": "string"},
"text": {"type": ["string", "null"]},
"logo": {"type": ["string", "null"]},
"brand_type": {"enum": [e.value for e in BrandType]},
"brand_type": {"enum": list(BrandType)},
},
"required": ["name"],
}
@@ -23,7 +23,7 @@ post_update_email_branding_schema = {
"name": {"type": ["string", "null"]},
"text": {"type": ["string", "null"]},
"logo": {"type": ["string", "null"]},
"brand_type": {"enum": [e.value for e in BrandType]},
"brand_type": {"enum": list(BrandType)},
},
"required": [],
}

View File

@@ -7,9 +7,7 @@ add_service_data_retention_request = {
"type": "object",
"properties": {
"days_of_retention": {"type": "integer"},
"notification_type": {
"enum": [NotificationType.SMS.value, NotificationType.EMAIL.value]
},
"notification_type": {"enum": [NotificationType.SMS, NotificationType.EMAIL]},
},
"required": ["days_of_retention", "notification_type"],
}

View File

@@ -68,7 +68,7 @@ def format_monthly_template_notification_stats(year, rows):
stats[formatted_month][str(row.template_id)] = {
"name": row.name,
"type": row.template_type,
"counts": dict.fromkeys([e.value for e in NotificationStatus], 0),
"counts": dict.fromkeys(list(NotificationStatus), 0),
}
stats[formatted_month][str(row.template_id)]["counts"][row.status] += row.count
@@ -83,17 +83,17 @@ def create_zeroed_stats_dicts():
def _update_statuses_from_row(update_dict, row):
if row.status != "cancelled":
if row.status != NotificationStatus.CANCELLED:
update_dict["requested"] += row.count
if row.status in ("delivered", "sent"):
if row.status in (NotificationStatus.DELIVERED, NotificationStatus.SENT):
update_dict["delivered"] += row.count
elif row.status in (
"failed",
"technical-failure",
"temporary-failure",
"permanent-failure",
"validation-failed",
"virus-scan-failed",
NotificationStatus.FAILED,
NotificationStatus.TECHNICAL_FAILURE,
NotificationStatus.TEMPORARY_FAILURE,
NotificationStatus.PERMANENT_FAILURE,
NotificationStatus.VALIDATION_FAILED,
NotificationStatus.VIRUS_SCAN_FAILED,
):
update_dict["failed"] += row.count

View File

@@ -8,15 +8,15 @@ post_create_template_schema = {
"title": "payload for POST /service/<uuid:service_id>/template",
"properties": {
"name": {"type": "string"},
"template_type": {"enum": [e.value for e in TemplateType]},
"template_type": {"enum": list(TemplateType)},
"service": uuid,
"process_type": {"enum": [e.value for e in TemplateProcessType]},
"process_type": {"enum": list(TemplateProcessType)},
"content": {"type": "string"},
"subject": {"type": "string"},
"created_by": uuid,
"parent_folder_id": uuid,
},
"if": {"properties": {"template_type": {"enum": [TemplateType.EMAIL.value]}}},
"if": {"properties": {"template_type": {"enum": [TemplateType.EMAIL]}}},
"then": {"required": ["subject"]},
"required": ["name", "template_type", "content", "service", "created_by"],
}
@@ -29,9 +29,9 @@ post_update_template_schema = {
"properties": {
"id": uuid,
"name": {"type": "string"},
"template_type": {"enum": [e.value for e in TemplateType]},
"template_type": {"enum": list(TemplateType)},
"service": uuid,
"process_type": {"enum": [e.value for e in TemplateProcessType]},
"process_type": {"enum": list(TemplateProcessType)},
"content": {"type": "string"},
"subject": {"type": "string"},
"reply_to": nullable_uuid,

View File

@@ -41,7 +41,7 @@ get_notification_response = {
"line_5": {"type": ["string", "null"]},
"line_6": {"type": ["string", "null"]},
"postcode": {"type": ["string", "null"]},
"type": {"enum": [e.value for e in TemplateType]},
"type": {"enum": list(TemplateType)},
"status": {"type": "string"},
"template": template,
"body": {"type": "string"},
@@ -82,11 +82,11 @@ get_notifications_request = {
"reference": {"type": "string"},
"status": {
"type": "array",
"items": {"enum": [e.value for e in NotificationStatus]},
"items": {"enum": list(NotificationStatus)},
},
"template_type": {
"type": "array",
"items": {"enum": [e.value for e in TemplateType]},
"items": {"enum": list(TemplateType)},
},
"include_jobs": {"enum": ["true", "True"]},
"older_than": uuid,

View File

@@ -17,7 +17,7 @@ get_template_by_id_response = {
"title": "reponse v2/template",
"properties": {
"id": uuid,
"type": {"enum": [e.value for e in TemplateType]},
"type": {"enum": list(TemplateType)},
"created_at": {
"format": "date-time",
"type": "string",
@@ -62,7 +62,7 @@ post_template_preview_response = {
"title": "reponse v2/template/{id}/preview",
"properties": {
"id": uuid,
"type": {"enum": [e.value for e in TemplateType]},
"type": {"enum": list(TemplateType)},
"version": {"type": "integer"},
"body": {"type": "string"},
"subject": {"type": ["string", "null"]},

View File

@@ -5,7 +5,7 @@ get_all_template_request = {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "request schema for parameters allowed when getting all templates",
"type": "object",
"properties": {"type": {"enum": [e.value for e in TemplateType]}},
"properties": {"type": {"enum": list(TemplateType)}},
"additionalProperties": False,
}