diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-04-06 13:28:07 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-04-06 13:28:07 +0200 |
commit | fefa25e7d89e1555cbecd9dc2b7d0f9e94f373fb (patch) | |
tree | 198cea230299e658d030d5d56f11f0b9c18d922a /src | |
parent | merge and fixed conflict (diff) | |
parent | wip (diff) | |
download | newspipe-fefa25e7d89e1555cbecd9dc2b7d0f9e94f373fb.tar.gz newspipe-fefa25e7d89e1555cbecd9dc2b7d0f9e94f373fb.tar.bz2 newspipe-fefa25e7d89e1555cbecd9dc2b7d0f9e94f373fb.zip |
Merge branch 'bookmark' of github.com:newspipe/newspipe into bookmark
Diffstat (limited to 'src')
-rw-r--r-- | src/web/models/bookmark.py | 15 | ||||
-rw-r--r-- | src/web/models/tag.py | 14 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/web/models/bookmark.py b/src/web/models/bookmark.py index b62285b7..6101a5f0 100644 --- a/src/web/models/bookmark.py +++ b/src/web/models/bookmark.py @@ -34,6 +34,12 @@ from sqlalchemy.ext.associationproxy import association_proxy from web.models.right_mixin import RightMixin +bookmarktags_table = db.Table('bookmarktags', db.metadata, + db.Column('bookmark_id', db.Integer, db.ForeignKey("bookmark.id"), + primary_key=True), + db.Column('tag_text', db.String, db.ForeignKey("BookmarkTag.text"), + primary_key=True) +) class Bookmark(db.Model, RightMixin): """ @@ -49,10 +55,11 @@ class Bookmark(db.Model, RightMixin): user_id = db.Column(db.Integer(), db.ForeignKey('user.id')) # relationships - tag_objs = db.relationship('BookmarkTag', back_populates='bookmark', - cascade='all,delete-orphan', - lazy=False, - foreign_keys='[BookmarkTag.bookmark_id]') + tag_objs = db.relationship("BookmarkTag", secondary=lambda: bookmarktags_table) + # tag_objs = db.relationship('BookmarkTag', back_populates='bookmark', + # cascade='all,delete-orphan', + # lazy=False, + # foreign_keys='[BookmarkTag.bookmark_id]') tags = association_proxy('tag_objs', 'text') diff --git a/src/web/models/tag.py b/src/web/models/tag.py index 28727dbf..c23d15ea 100644 --- a/src/web/models/tag.py +++ b/src/web/models/tag.py @@ -20,15 +20,19 @@ class ArticleTag(db.Model): class BookmarkTag(db.Model): - text = db.Column(db.String, primary_key=True, unique=False) + __tablename__ = 'BookmarkTag' + #id = db.Column(db.Integer, primary_key=True) + text = db.Column(db.String, primary_key=True) # foreign keys - bookmark_id = db.Column(db.Integer, db.ForeignKey('bookmark.id', ondelete='CASCADE'), - primary_key=True) + # bookmark_id = db.Column(db.Integer, db.ForeignKey('bookmark.id', ondelete='CASCADE'), + # primary_key=True) # relationships - bookmark = db.relationship('Bookmark', back_populates='tag_objs', - foreign_keys=[bookmark_id]) + # bookmark = db.relationship('Bookmark', back_populates='tag_objs', + # single_parent=True, + # cascade="all, delete-orphan", + # foreign_keys=[bookmark_id]) def __init__(self, text): self.text = text |