aboutsummaryrefslogtreecommitdiff
path: root/src/web/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/controllers')
-rw-r--r--src/web/controllers/__init__.py3
-rw-r--r--src/web/controllers/abstract.py13
-rw-r--r--src/web/controllers/bookmark.py20
3 files changed, 29 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..074ce24c 100644
--- a/src/web/controllers/abstract.py
+++ b/src/web/controllers/abstract.py
@@ -98,14 +98,15 @@ 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)
+ print(attrs)
+ 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..f7dab9d8
--- /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.tag_objs = attrs['tags']
+ return super().update(filters, attrs, *args, **kwargs)
bgstack15