mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-26 01:03:41 -04:00
Merge pull request #2880 from alphagov/serialise-less-stuff-templates
Exclude unneeded fields from all templates response
This commit is contained in:
@@ -363,6 +363,28 @@ class TemplateSchema(BaseTemplateSchema):
|
||||
exclude = BaseTemplateSchema.Meta.exclude + ('created_by',)
|
||||
|
||||
|
||||
class TemplateSchemaNoDetail(TemplateSchema):
|
||||
class Meta(TemplateSchema.Meta):
|
||||
exclude = TemplateSchema.Meta.exclude + (
|
||||
'archived',
|
||||
'content',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'hidden',
|
||||
'postage',
|
||||
'process_type',
|
||||
'redact_personalisation',
|
||||
'reply_to',
|
||||
'reply_to_text',
|
||||
'service',
|
||||
'service_letter_contact',
|
||||
'subject',
|
||||
'template_redacted',
|
||||
'updated_at',
|
||||
'version',
|
||||
)
|
||||
|
||||
|
||||
class TemplateHistorySchema(BaseSchema):
|
||||
|
||||
reply_to = fields.Method("get_reply_to", allow_none=True)
|
||||
@@ -674,6 +696,7 @@ user_update_password_schema_load_json = UserUpdatePasswordSchema(load_json=True,
|
||||
service_schema = ServiceSchema()
|
||||
detailed_service_schema = DetailedServiceSchema()
|
||||
template_schema = TemplateSchema()
|
||||
template_schema_no_detail = TemplateSchemaNoDetail()
|
||||
api_key_schema = ApiKeySchema()
|
||||
job_schema = JobSchema()
|
||||
sms_template_notification_schema = SmsTemplateNotificationSchema()
|
||||
|
||||
@@ -36,7 +36,7 @@ from app.letters.utils import get_letter_pdf_and_metadata
|
||||
from app.models import SMS_TYPE, Template, SECOND_CLASS, LETTER_TYPE
|
||||
from app.notifications.validators import service_has_permission, check_reply_to
|
||||
from app.schema_validation import validate
|
||||
from app.schemas import (template_schema, template_history_schema)
|
||||
from app.schemas import (template_schema, template_schema_no_detail, template_history_schema)
|
||||
from app.template.template_schemas import post_create_template_schema, post_update_template_schema
|
||||
from app.utils import get_public_notify_type_text
|
||||
|
||||
@@ -152,7 +152,10 @@ def get_precompiled_template_for_service(service_id):
|
||||
@template_blueprint.route('', methods=['GET'])
|
||||
def get_all_templates_for_service(service_id):
|
||||
templates = dao_get_all_templates_for_service(service_id=service_id)
|
||||
data = template_schema.dump(templates, many=True).data
|
||||
if str(request.args.get('detailed', True)) == 'True':
|
||||
data = template_schema.dump(templates, many=True).data
|
||||
else:
|
||||
data = template_schema_no_detail.dump(templates, many=True).data
|
||||
return jsonify(data=data)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user