More cleanup.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-01-10 09:48:32 -05:00
parent df10c4693c
commit 908d695b54
9 changed files with 23 additions and 21 deletions

View File

@@ -33,7 +33,6 @@ from app.utils import (
class TemplateType(Enum):
SMS = "sms"
EMAIL = "email"
LETTER = "letter"
class NotificationType(Enum):

View File

@@ -2,7 +2,7 @@ from collections import defaultdict
from datetime import datetime
from app.dao.date_util import get_months_for_financial_year
from app.models import NOTIFICATION_STATUS_TYPES, NOTIFICATION_TYPES
from app.models import NOTIFICATION_STATUS_TYPES, TemplateType
def format_statistics(statistics):
@@ -40,7 +40,7 @@ def format_admin_stats(statistics):
def create_stats_dict():
stats_dict = {}
for template in NOTIFICATION_TYPES:
for template in TemplateType:
stats_dict[template] = {}
for status in ("total", "test-key"):
@@ -78,7 +78,7 @@ def format_monthly_template_notification_stats(year, rows):
def create_zeroed_stats_dicts():
return {
template_type: {status: 0 for status in ("requested", "delivered", "failed")}
for template_type in NOTIFICATION_TYPES
for template_type in TemplateType
}
@@ -103,7 +103,7 @@ def create_empty_monthly_notification_status_stats_dict(year):
# nested dicts - data[month][template type][status] = count
return {
start.strftime("%Y-%m"): {
template_type: defaultdict(int) for template_type in NOTIFICATION_TYPES
template_type: defaultdict(int) for template_type in TemplateType
}
for start in utc_month_starts
}

View File

@@ -1,4 +1,4 @@
from app.models import TEMPLATE_PROCESS_TYPE, TEMPLATE_TYPES
from app.models import TEMPLATE_PROCESS_TYPE, TemplateType
from app.schema_validation.definitions import nullable_uuid, uuid
post_create_template_schema = {
@@ -8,7 +8,7 @@ post_create_template_schema = {
"title": "payload for POST /service/<uuid:service_id>/template",
"properties": {
"name": {"type": "string"},
"template_type": {"enum": TEMPLATE_TYPES},
"template_type": {"enum": [e.value for e in TemplateType]},
"service": uuid,
"process_type": {"enum": TEMPLATE_PROCESS_TYPE},
"content": {"type": "string"},
@@ -29,7 +29,7 @@ post_update_template_schema = {
"properties": {
"id": uuid,
"name": {"type": "string"},
"template_type": {"enum": TEMPLATE_TYPES},
"template_type": {"enum": [e.value for e in TemplateType]},
"service": uuid,
"process_type": {"enum": TEMPLATE_PROCESS_TYPE},
"content": {"type": "string"},

View File

@@ -1,4 +1,4 @@
from app.models import NOTIFICATION_STATUS_TYPES, NOTIFICATION_TYPES
from app.models import NOTIFICATION_STATUS_TYPES, TemplateType
from app.schema_validation.definitions import personalisation, uuid
template = {
@@ -81,7 +81,10 @@ get_notifications_request = {
"properties": {
"reference": {"type": "string"},
"status": {"type": "array", "items": {"enum": NOTIFICATION_STATUS_TYPES}},
"template_type": {"type": "array", "items": {"enum": NOTIFICATION_TYPES}},
"template_type": {
"type": "array",
"items": {"enum": [e.value for e in TemplateType]},
},
"include_jobs": {"enum": ["true", "True"]},
"older_than": uuid,
},

View File

@@ -1,4 +1,4 @@
from app.models import TEMPLATE_TYPES
from app.models import TemplateType
from app.schema_validation.definitions import personalisation, uuid
get_template_by_id_request = {
@@ -17,7 +17,7 @@ get_template_by_id_response = {
"title": "reponse v2/template",
"properties": {
"id": uuid,
"type": {"enum": TEMPLATE_TYPES},
"type": {"enum": [e.value for e in 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": TEMPLATE_TYPES},
"type": {"enum": [e.value for e in TemplateType]},
"version": {"type": "integer"},
"body": {"type": "string"},
"subject": {"type": ["string", "null"]},

View File

@@ -1,11 +1,11 @@
from app.models import TEMPLATE_TYPES
from app.models import TemplateType
from app.v2.template.template_schemas import get_template_by_id_response as template
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": TEMPLATE_TYPES}},
"properties": {"type": {"enum": [e.value for e in TemplateType]}},
"additionalProperties": False,
}