mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-11 09:27:56 -04:00
Add TemplateHistory.redact_personalisation attribute
TemplateHistory objects need to be connected to the template's TemplateRedacted record. This requires setting up a new SQLAlchemy relationship to allow accessing redact_personalisation from TemplateHistory instances. We can avoid creating a foreign key in this case by setting up an explicit `primaryjoin` expression. Since TemplateHistory.id is created from Template.id and TemplateRedacted.template_id is already a foreign key to Template.id the foreign key should always be valid even without a DB constraint.
This commit is contained in:
@@ -645,6 +645,11 @@ class TemplateHistory(db.Model):
|
||||
nullable=False,
|
||||
default=NORMAL)
|
||||
|
||||
template_redacted = db.relationship('TemplateRedacted', foreign_keys=[id],
|
||||
primaryjoin='TemplateRedacted.template_id == TemplateHistory.id')
|
||||
|
||||
redact_personalisation = association_proxy('template_redacted', 'redact_personalisation')
|
||||
|
||||
def get_link(self):
|
||||
return url_for(
|
||||
"v2_template.get_template_by_id",
|
||||
|
||||
Reference in New Issue
Block a user