Refactor to use is_precompiled_letter in letters/utils.py

This commit is contained in:
Ken Tsang
2018-03-06 13:04:57 +00:00
parent bca858f4a8
commit 28136734e4
3 changed files with 10 additions and 12 deletions

View File

@@ -14,6 +14,7 @@ from app.dao.templates_dao import (
dao_get_template_by_id_and_service_id
)
from app.letters.utils import is_precompiled_letter
from app.schemas import notification_with_template_schema
from app.utils import cache_key_for_service_template_counter
from app.errors import register_errors, InvalidRequest
@@ -48,11 +49,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.template_type == 'letter' and
data.hidden and
data.name == current_app.config['PRECOMPILED_TEMPLATE_NAME']
)
'precompiled_letter': is_precompiled_letter(data)
}
return jsonify(data=[serialize(row) for row in stats])