aboutsummaryrefslogtreecommitdiff
path: root/src/web/controllers
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-23 15:31:07 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-23 15:31:07 +0200
commitb02a3c469e238892a1c13d32c1e208d35e7885ce (patch)
tree814abd1cf5e06b139c5978ace289ad2ad20d2c9c /src/web/controllers
parentRemoved debug print (diff)
downloadnewspipe-b02a3c469e238892a1c13d32c1e208d35e7885ce.tar.gz
newspipe-b02a3c469e238892a1c13d32c1e208d35e7885ce.tar.bz2
newspipe-b02a3c469e238892a1c13d32c1e208d35e7885ce.zip
Update tags of bookmarks.
Diffstat (limited to 'src/web/controllers')
-rw-r--r--src/web/controllers/__init__.py4
-rw-r--r--src/web/controllers/bookmark.py17
-rw-r--r--src/web/controllers/tag.py19
3 files changed, 35 insertions, 5 deletions
diff --git a/src/web/controllers/__init__.py b/src/web/controllers/__init__.py
index dd497e9a..5fbc2619 100644
--- a/src/web/controllers/__init__.py
+++ b/src/web/controllers/__init__.py
@@ -4,7 +4,9 @@ from .article import ArticleController
from .user import UserController
from .icon import IconController
from .bookmark import BookmarkController
+from .tag import BookmarkTagController
__all__ = ['FeedController', 'CategoryController', 'ArticleController',
- 'UserController', 'IconController', 'BookmarkController']
+ 'UserController', 'IconController', 'BookmarkController',
+ 'BookmarkTagController']
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)
diff --git a/src/web/controllers/tag.py b/src/web/controllers/tag.py
new file mode 100644
index 00000000..a40387c9
--- /dev/null
+++ b/src/web/controllers/tag.py
@@ -0,0 +1,19 @@
+import logging
+import itertools
+from datetime import datetime, timedelta
+
+from bootstrap import db
+from .abstract import AbstractController
+from web.models.tag import BookmarkTag
+
+logger = logging.getLogger(__name__)
+
+
+class BookmarkTagController(AbstractController):
+ _db_cls = BookmarkTag
+
+ def count_by_href(self, **filters):
+ return self._count_by(BookmarkTag.text, filters)
+
+ def update(self, filters, attrs):
+ return super().update(filters, attrs)
bgstack15