diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-05-23 15:37:50 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-05-23 15:37:50 +0200 |
commit | a756a3e9da58df6247e3437be4c13da25dab1aa0 (patch) | |
tree | 60281271606a5cc6b718d65d998c2d97b3fa4c50 /src/web/controllers | |
parent | Added UTF-8 version of the logo. (diff) | |
parent | Update tags of bookmarks. (diff) | |
download | newspipe-a756a3e9da58df6247e3437be4c13da25dab1aa0.tar.gz newspipe-a756a3e9da58df6247e3437be4c13da25dab1aa0.tar.bz2 newspipe-a756a3e9da58df6247e3437be4c13da25dab1aa0.zip |
Fixed conflicts.
Diffstat (limited to 'src/web/controllers')
-rw-r--r-- | src/web/controllers/__init__.py | 5 | ||||
-rw-r--r-- | src/web/controllers/abstract.py | 1 | ||||
-rw-r--r-- | src/web/controllers/bookmark.py | 29 | ||||
-rw-r--r-- | src/web/controllers/tag.py | 19 |
4 files changed, 52 insertions, 2 deletions
diff --git a/src/web/controllers/__init__.py b/src/web/controllers/__init__.py index a1b89ea8..5fbc2619 100644 --- a/src/web/controllers/__init__.py +++ b/src/web/controllers/__init__.py @@ -3,7 +3,10 @@ from .category import CategoryController 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'] + 'UserController', 'IconController', 'BookmarkController', + 'BookmarkTagController'] diff --git a/src/web/controllers/abstract.py b/src/web/controllers/abstract.py index 074ce24c..8563d5f2 100644 --- a/src/web/controllers/abstract.py +++ b/src/web/controllers/abstract.py @@ -100,7 +100,6 @@ class AbstractController: def update(self, filters, attrs, return_objs=False, commit=True): assert attrs, "attributes to update must not be empty" - print(attrs) result = self._get(**filters).update(attrs, synchronize_session=False) if commit: db.session.flush() diff --git a/src/web/controllers/bookmark.py b/src/web/controllers/bookmark.py new file mode 100644 index 00000000..c8423414 --- /dev/null +++ b/src/web/controllers/bookmark.py @@ -0,0 +1,29 @@ +import logging +import itertools +from datetime import datetime, timedelta + +from bootstrap import db +from web.models import Bookmark +from .abstract import AbstractController +from .tag import BookmarkTagController + +logger = logging.getLogger(__name__) + + +class BookmarkController(AbstractController): + _db_cls = Bookmark + + def count_by_href(self, **filters): + return self._count_by(Bookmark.href, filters) + + 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) |