mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 06:03:12 -04:00
rename actual_template to template_history
it's slightly less emotionally charged
This commit is contained in:
@@ -357,7 +357,7 @@ def get_notification_with_personalisation(service_id, notification_id, key_type)
|
|||||||
if key_type:
|
if key_type:
|
||||||
filter_dict['key_type'] = 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")
|
@statsd(namespace="dao")
|
||||||
@@ -392,7 +392,7 @@ def get_notifications_for_service(service_id,
|
|||||||
query = _filter_query(query, filter_dict)
|
query = _filter_query(query, filter_dict)
|
||||||
if personalisation:
|
if personalisation:
|
||||||
query = query.options(
|
query = query.options(
|
||||||
joinedload('actual_template')
|
joinedload('template_history')
|
||||||
)
|
)
|
||||||
return query.order_by(desc(Notification.created_at)).paginate(
|
return query.order_by(desc(Notification.created_at)).paginate(
|
||||||
page=page,
|
page=page,
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ class Notification(db.Model):
|
|||||||
reference = db.Column(db.String, nullable=True, index=True)
|
reference = db.Column(db.String, nullable=True, index=True)
|
||||||
_personalisation = db.Column(db.String, nullable=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_id) == remote(TemplateHistory.id),
|
||||||
foreign(template_version) == remote(TemplateHistory.version)
|
foreign(template_version) == remote(TemplateHistory.version)
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -292,9 +292,9 @@ class NotificationWithTemplateSchema(BaseSchema):
|
|||||||
|
|
||||||
|
|
||||||
class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema):
|
class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema):
|
||||||
actual_template = fields.Nested(TemplateHistorySchema,
|
template_history = fields.Nested(TemplateHistorySchema,
|
||||||
only=['id', 'name', 'template_type', 'content', 'subject', 'version'],
|
only=['id', 'name', 'template_type', 'content', 'subject', 'version'],
|
||||||
dump_only=True)
|
dump_only=True)
|
||||||
|
|
||||||
class Meta(NotificationWithTemplateSchema.Meta):
|
class Meta(NotificationWithTemplateSchema.Meta):
|
||||||
# mark as many fields as possible as required since this is a public api.
|
# mark as many fields as possible as required since this is a public api.
|
||||||
@@ -307,7 +307,7 @@ class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema):
|
|||||||
# computed fields
|
# computed fields
|
||||||
'personalisation',
|
'personalisation',
|
||||||
# relationships
|
# relationships
|
||||||
'service', 'job', 'api_key', 'actual_template'
|
'service', 'job', 'api_key', 'template_history'
|
||||||
)
|
)
|
||||||
|
|
||||||
@pre_dump
|
@pre_dump
|
||||||
@@ -317,7 +317,7 @@ class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema):
|
|||||||
|
|
||||||
@post_dump
|
@post_dump
|
||||||
def handle_template_merge(self, in_data):
|
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
|
from notifications_utils.template import Template
|
||||||
template = Template(
|
template = Template(
|
||||||
in_data['template'],
|
in_data['template'],
|
||||||
|
|||||||
Reference in New Issue
Block a user