aboutsummaryrefslogtreecommitdiff
path: root/src/web/models/article.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/models/article.py')
-rw-r--r--src/web/models/article.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/web/models/article.py b/src/web/models/article.py
index 23708f6b..5261cb0d 100644
--- a/src/web/models/article.py
+++ b/src/web/models/article.py
@@ -29,6 +29,8 @@ __license__ = "GPLv3"
from bootstrap import db
from datetime import datetime
from sqlalchemy import asc, desc, Index
+from sqlalchemy.ext.associationproxy import association_proxy
+
from web.models.right_mixin import RightMixin
@@ -49,6 +51,13 @@ class Article(db.Model, RightMixin):
feed_id = db.Column(db.Integer(), db.ForeignKey('feed.id'))
category_id = db.Column(db.Integer(), db.ForeignKey('category.id'))
+ # relationships
+ tag_objs = db.relationship('Tag', back_populates='article',
+ cascade='all,delete-orphan',
+ lazy=False,
+ foreign_keys='[Tag.article_id]')
+ tags = association_proxy('tag_objs', 'text')
+
# index
idx_article_uid = Index('user_id')
idx_article_uid_cid = Index('user_id', 'category_id')
bgstack15