mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-25 02:19:45 -04:00
Refactored to use template response as template
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from app.models import SMS_TYPE, TEMPLATE_TYPES
|
||||
from app.schema_validation.definitions import uuid, personalisation
|
||||
from app.v2.template_schema import template
|
||||
|
||||
|
||||
get_template_by_id_request = {
|
||||
@@ -68,51 +67,6 @@ post_template_preview_response = {
|
||||
"required": ["id", "type", "version", "body"]
|
||||
}
|
||||
|
||||
get_all_template_request = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "request schema for parameters allowed when getting all templates",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {"enum": TEMPLATE_TYPES},
|
||||
},
|
||||
"required": ["type"],
|
||||
"additionalProperties": False,
|
||||
}
|
||||
|
||||
get_all_template_response = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "GET response schema when getting all templates",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"links": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"self": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"next": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"required": ["self"],
|
||||
},
|
||||
"templates": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/template"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["links", "templates"],
|
||||
"definitions": {
|
||||
"template": template
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def create_post_template_preview_response(template, template_object):
|
||||
subject = template_object.subject if template.template_type != SMS_TYPE else None
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
from app.schema_validation.definitions import uuid
|
||||
|
||||
# this may belong in a templates module
|
||||
template = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "template schema",
|
||||
"type": "object",
|
||||
"title": "notification content",
|
||||
"properties": {
|
||||
"id": uuid,
|
||||
"version": {"type": "integer"},
|
||||
"uri": {"type": "string", "format": "uri"}
|
||||
},
|
||||
"required": ["id", "version", "uri"]
|
||||
}
|
||||
@@ -14,6 +14,8 @@ def get_templates():
|
||||
|
||||
templates = templates_dao.dao_get_all_templates_for_service(api_user.service_id)
|
||||
|
||||
print(templates)
|
||||
|
||||
return jsonify(
|
||||
templates=[template.serialize() for template in templates]
|
||||
), 200
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from app.models import TEMPLATE_TYPES
|
||||
from app.v2.template_schema import template
|
||||
from app.v2.template.template_schemas import get_template_by_id_response as template
|
||||
|
||||
|
||||
get_all_template_request = {
|
||||
|
||||
Reference in New Issue
Block a user