From 5b3a0f03d342dc3d6811789b8b6829ab996032c4 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Wed, 10 Aug 2016 16:57:27 +0100 Subject: [PATCH] rename actual_template to template_history it's slightly less emotionally charged --- app/dao/notifications_dao.py | 4 ++-- app/models.py | 2 +- app/schemas.py | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index 1e85d6cab..d944a3202 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -357,7 +357,7 @@ def get_notification_with_personalisation(service_id, notification_id, key_type) if key_type: filter_dict['key_type'] = key_type - return Notification.query.filter_by(**filter_dict).options(joinedload('actual_template')).one() + return Notification.query.filter_by(**filter_dict).options(joinedload('template_history')).one() @statsd(namespace="dao") @@ -392,7 +392,7 @@ def get_notifications_for_service(service_id, query = _filter_query(query, filter_dict) if personalisation: query = query.options( - joinedload('actual_template') + joinedload('template_history') ) return query.order_by(desc(Notification.created_at)).paginate( page=page, diff --git a/app/models.py b/app/models.py index ae52827c4..d391022c7 100644 --- a/app/models.py +++ b/app/models.py @@ -448,7 +448,7 @@ class Notification(db.Model): reference = db.Column(db.String, nullable=True, index=True) _personalisation = db.Column(db.String, nullable=True) - actual_template = db.relationship('TemplateHistory', primaryjoin=and_( + template_history = db.relationship('TemplateHistory', primaryjoin=and_( foreign(template_id) == remote(TemplateHistory.id), foreign(template_version) == remote(TemplateHistory.version) )) diff --git a/app/schemas.py b/app/schemas.py index 7cad5de42..977c378fc 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -292,9 +292,9 @@ class NotificationWithTemplateSchema(BaseSchema): class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema): - actual_template = fields.Nested(TemplateHistorySchema, - only=['id', 'name', 'template_type', 'content', 'subject', 'version'], - dump_only=True) + template_history = fields.Nested(TemplateHistorySchema, + only=['id', 'name', 'template_type', 'content', 'subject', 'version'], + dump_only=True) class Meta(NotificationWithTemplateSchema.Meta): # mark as many fields as possible as required since this is a public api. @@ -307,7 +307,7 @@ class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema): # computed fields 'personalisation', # relationships - 'service', 'job', 'api_key', 'actual_template' + 'service', 'job', 'api_key', 'template_history' ) @pre_dump @@ -317,7 +317,7 @@ class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema): @post_dump def handle_template_merge(self, in_data): - in_data['template'] = in_data.pop('actual_template') + in_data['template'] = in_data.pop('template_history') from notifications_utils.template import Template template = Template( in_data['template'],