aboutsummaryrefslogtreecommitdiff
path: root/newspipe/controllers/bookmark.py
diff options
context:
space:
mode:
Diffstat (limited to 'newspipe/controllers/bookmark.py')
-rw-r--r--newspipe/controllers/bookmark.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/newspipe/controllers/bookmark.py b/newspipe/controllers/bookmark.py
new file mode 100644
index 00000000..3c9dcce9
--- /dev/null
+++ b/newspipe/controllers/bookmark.py
@@ -0,0 +1,35 @@
+import logging
+import itertools
+from datetime import datetime, timedelta
+
+from newspipe.bootstrap import db
+from newspipe.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).create(
+ **{
+ "text": tag.text,
+ "id": tag.id,
+ "bookmark_id": tag.bookmark_id,
+ "user_id": tag.user_id,
+ }
+ )
+
+ del attrs["tags"]
+ return super().update(filters, attrs)
bgstack15