diff options
Diffstat (limited to 'src/web/controllers/bookmark.py')
-rw-r--r-- | src/web/controllers/bookmark.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/web/controllers/bookmark.py b/src/web/controllers/bookmark.py index f7dab9d8..c8423414 100644 --- a/src/web/controllers/bookmark.py +++ b/src/web/controllers/bookmark.py @@ -3,8 +3,9 @@ import itertools from datetime import datetime, timedelta from bootstrap import db -from .abstract import AbstractController from web.models import Bookmark +from .abstract import AbstractController +from .tag import BookmarkTagController logger = logging.getLogger(__name__) @@ -15,6 +16,14 @@ class BookmarkController(AbstractController): def count_by_href(self, **filters): return self._count_by(Bookmark.href, filters) - def update(self, filters, attrs, *args, **kwargs): - #self.tag_objs = attrs['tags'] - return super().update(filters, attrs, *args, **kwargs) + def update(self, filters, attrs): + BookmarkTagController(self.user_id) \ + .read(**{'bookmark_id': filters["id"]}) \ + .delete() + + for tag in attrs['tags']: + BookmarkTagController(self.user_id) \ + .update({'id': tag.id}, {'bookmark_id': filters["id"]}) + + del attrs['tags'] + return super().update(filters, attrs) |