mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
add actual_template relationship to notification
also renamed the function to make it apparent that it'll join and grab personalisation
This commit is contained in:
@@ -5,7 +5,8 @@ from sqlalchemy.dialects.postgresql import (
|
||||
UUID,
|
||||
JSON
|
||||
)
|
||||
from sqlalchemy import UniqueConstraint, text
|
||||
from sqlalchemy import UniqueConstraint, text, ForeignKeyConstraint, and_
|
||||
from sqlalchemy.orm import foreign, remote
|
||||
|
||||
from app.encryption import (
|
||||
hashpw,
|
||||
@@ -447,6 +448,14 @@ class Notification(db.Model):
|
||||
reference = db.Column(db.String, nullable=True, index=True)
|
||||
_personalisation = db.Column(db.String, nullable=True)
|
||||
|
||||
# __table_args__ = (
|
||||
# ForeignKeyConstraint(['template_id', 'template_version'], ['template_history.id', 'template_history.version']),
|
||||
# )
|
||||
actual_template = db.relationship('TemplateHistory', primaryjoin=and_(
|
||||
foreign(template_id) == remote(TemplateHistory.id),
|
||||
foreign(template_version) == remote(TemplateHistory.version)
|
||||
))
|
||||
|
||||
@property
|
||||
def personalisation(self):
|
||||
if self._personalisation:
|
||||
|
||||
Reference in New Issue
Block a user