diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-02-12 16:41:09 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-02-12 16:41:09 +0100 |
commit | 8bd82176356540b88eece24b96d7eb6a2260d718 (patch) | |
tree | 619caf62c174d09448e3da9c873b2df0d26dd5c2 /src/web/controllers | |
parent | New https certificate (diff) | |
download | newspipe-8bd82176356540b88eece24b96d7eb6a2260d718.tar.gz newspipe-8bd82176356540b88eece24b96d7eb6a2260d718.tar.bz2 newspipe-8bd82176356540b88eece24b96d7eb6a2260d718.zip |
prototypefor bookmarks
Diffstat (limited to 'src/web/controllers')
-rw-r--r-- | src/web/controllers/__init__.py | 3 | ||||
-rw-r--r-- | src/web/controllers/abstract.py | 12 | ||||
-rw-r--r-- | src/web/controllers/bookmark.py | 20 |
3 files changed, 28 insertions, 7 deletions
diff --git a/src/web/controllers/__init__.py b/src/web/controllers/__init__.py index a1b89ea8..dd497e9a 100644 --- a/src/web/controllers/__init__.py +++ b/src/web/controllers/__init__.py @@ -3,7 +3,8 @@ from .category import CategoryController from .article import ArticleController from .user import UserController from .icon import IconController +from .bookmark import BookmarkController __all__ = ['FeedController', 'CategoryController', 'ArticleController', - 'UserController', 'IconController'] + 'UserController', 'IconController', 'BookmarkController'] diff --git a/src/web/controllers/abstract.py b/src/web/controllers/abstract.py index 3c91e08a..8563d5f2 100644 --- a/src/web/controllers/abstract.py +++ b/src/web/controllers/abstract.py @@ -98,14 +98,14 @@ class AbstractController: def read(self, **filters): return self._get(**filters) - def update(self, filters, attrs): + def update(self, filters, attrs, return_objs=False, commit=True): assert attrs, "attributes to update must not be empty" - result = None - try: - result = self._get(**filters).update(attrs, synchronize_session=False) + result = self._get(**filters).update(attrs, synchronize_session=False) + if commit: + db.session.flush() db.session.commit() - except Exception as e: - db.session.rollback() + if return_objs: + return self._get(**filters) return result def delete(self, obj_id): diff --git a/src/web/controllers/bookmark.py b/src/web/controllers/bookmark.py new file mode 100644 index 00000000..cf7815a8 --- /dev/null +++ b/src/web/controllers/bookmark.py @@ -0,0 +1,20 @@ +import logging +import itertools +from datetime import datetime, timedelta + +from bootstrap import db +from .abstract import AbstractController +from web.models import Bookmark + +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, *args, **kwargs): + self.tags = attrs['tags'] + return super().update(filters, attrs, *args, **kwargs) |