diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-05-23 15:31:07 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-05-23 15:31:07 +0200 |
commit | b02a3c469e238892a1c13d32c1e208d35e7885ce (patch) | |
tree | 814abd1cf5e06b139c5978ace289ad2ad20d2c9c /src/web/models/bookmark.py | |
parent | Removed debug print (diff) | |
download | newspipe-b02a3c469e238892a1c13d32c1e208d35e7885ce.tar.gz newspipe-b02a3c469e238892a1c13d32c1e208d35e7885ce.tar.bz2 newspipe-b02a3c469e238892a1c13d32c1e208d35e7885ce.zip |
Update tags of bookmarks.
Diffstat (limited to 'src/web/models/bookmark.py')
-rw-r--r-- | src/web/models/bookmark.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/web/models/bookmark.py b/src/web/models/bookmark.py index 891c3eda..6eee3cba 100644 --- a/src/web/models/bookmark.py +++ b/src/web/models/bookmark.py @@ -28,9 +28,11 @@ __license__ = "GPLv3" from bootstrap import db from datetime import datetime +from sqlalchemy import desc from sqlalchemy.orm import validates from sqlalchemy.ext.associationproxy import association_proxy +from web.models.tag import BookmarkTag from web.models.right_mixin import RightMixin @@ -48,11 +50,10 @@ 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]') - tags = association_proxy('tag_objs', 'text') + tags = db.relationship(BookmarkTag, backref='of_bookmark', lazy='dynamic', + cascade='all,delete-orphan', + order_by=desc(BookmarkTag.text)) + tags_proxy = association_proxy('tags', 'text') @validates('description') |