Update response to return is_precompiled_letter

This commit is contained in:
Ken Tsang
2018-03-07 23:02:38 +00:00
parent 7011b90bd4
commit 23ce36dc48
3 changed files with 4 additions and 12 deletions

View File

@@ -305,7 +305,6 @@ class NotificationModelSchema(BaseSchema):
class BaseTemplateSchema(BaseSchema):
reply_to = fields.Method("get_reply_to", allow_none=True)
reply_to_text = fields.Method("get_reply_to_text", allow_none=True)
precompiled_letter = fields.Method("get_precompiled_letter")
def get_reply_to(self, template):
return template.reply_to
@@ -313,9 +312,6 @@ class BaseTemplateSchema(BaseSchema):
def get_reply_to_text(self, template):
return template.get_reply_to_text()
def get_precompiled_letter(self, template):
return template.is_precompiled_letter
class Meta:
model = models.Template
exclude = ("service_id", "jobs", "service_letter_contact_id")
@@ -466,7 +462,7 @@ class NotificationWithTemplateSchema(BaseSchema):
'content',
'subject',
'redact_personalisation',
'precompiled_letter'
'is_precompiled_letter'
],
dump_only=True
)

View File

@@ -68,7 +68,7 @@ from app.errors import (
InvalidRequest,
register_errors
)
from app.models import Service, EmailBranding, LETTER_TYPE, PRECOMPILED_TEMPLATE_NAME
from app.models import Service, EmailBranding
from app.schema_validation import validate
from app.service import statistics
from app.service.service_senders_schema import (
@@ -537,11 +537,7 @@ def get_monthly_template_usage(service_id):
'month': i.month,
'year': i.year,
'count': i.count,
'precompiled_letter': (
i.template_type == LETTER_TYPE and
i.hidden and
i.name == PRECOMPILED_TEMPLATE_NAME
)
'is_precompiled_letter': i.is_precompiled_letter
}
)

View File

@@ -48,7 +48,7 @@ def get_template_statistics_for_service_by_day(service_id):
'template_id': str(data.template_id),
'template_name': data.name,
'template_type': data.template_type,
'precompiled_letter': data.is_precompiled_letter
'is_precompiled_letter': data.is_precompiled_letter
}
return jsonify(data=[serialize(row) for row in stats])