aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-29 23:15:17 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-29 23:15:17 +0200
commit83f3c20fa76ff383d069ca866cb2eee92fe0c9c8 (patch)
tree52769a06701637218935fd2db777d4cfd796e562 /src
parentMore human readable date format. (diff)
downloadnewspipe-83f3c20fa76ff383d069ca866cb2eee92fe0c9c8.tar.gz
newspipe-83f3c20fa76ff383d069ca866cb2eee92fe0c9c8.tar.bz2
newspipe-83f3c20fa76ff383d069ca866cb2eee92fe0c9c8.zip
It is now possible to filter bookmarks by tags.
Diffstat (limited to 'src')
-rw-r--r--src/web/controllers/abstract.py2
-rw-r--r--src/web/templates/bookmarks.html2
-rw-r--r--src/web/views/bookmark.py8
3 files changed, 9 insertions, 3 deletions
diff --git a/src/web/controllers/abstract.py b/src/web/controllers/abstract.py
index 8563d5f2..47cc365f 100644
--- a/src/web/controllers/abstract.py
+++ b/src/web/controllers/abstract.py
@@ -50,6 +50,8 @@ class AbstractController:
db_filters.add(getattr(self._db_cls, key[:-4]) != value)
elif key.endswith('__in'):
db_filters.add(getattr(self._db_cls, key[:-4]).in_(value))
+ elif key.endswith('__contains'):
+ db_filters.add(getattr(self._db_cls, key[:-10]).contains(value))
elif key.endswith('__like'):
db_filters.add(getattr(self._db_cls, key[:-6]).like(value))
elif key.endswith('__ilike'):
diff --git a/src/web/templates/bookmarks.html b/src/web/templates/bookmarks.html
index 3c4cc0db..7ccddeed 100644
--- a/src/web/templates/bookmarks.html
+++ b/src/web/templates/bookmarks.html
@@ -24,7 +24,7 @@
</h4>
<p class="list-group-item-text">
<div class="text-muted">{{ bookmark.description }}</div>
- <div>{{ " ".join(bookmark.tags_proxy) }}</div>
+ <div>{% for tag in bookmark.tags %}<a href="{{ url_for('bookmarks.list_', tag=tag.text) }}">{{ tag.text }}</a>{% endfor %}</div>
{{ bookmark.time | datetime }}
{% if current_user.is_authenticated %}
<a class="text-muted" href="{{ url_for('bookmark.form', bookmark_id=bookmark.id) }}">edit</a>
diff --git a/src/web/views/bookmark.py b/src/web/views/bookmark.py
index 841d7364..8736e1ca 100644
--- a/src/web/views/bookmark.py
+++ b/src/web/views/bookmark.py
@@ -54,10 +54,13 @@ bookmark_bp = Blueprint('bookmark', __name__, url_prefix='/bookmark')
def list_(per_page, status='all'):
"Lists the bookmarks."
head_titles = [gettext("Bookmarks")]
+ filters = {}
+ tag = request.args.get('tag', None)
+ if tag:
+ filters['tags_proxy__contains'] = tag
if current_user.is_authenticated:
# query for the bookmarks of the authenticated user
- filters = {}
if status == 'public':
filters['shared'] = True
elif status == 'private':
@@ -72,7 +75,8 @@ def list_(per_page, status='all'):
bookmark_query = BookmarkController(current_user.id).read(**filters)
else:
# query for the shared bookmarks (of all users)
- bookmark_query = BookmarkController().read(**{'shared': True})
+ filters['shared'] = True
+ bookmark_query = BookmarkController().read(**filters)
bookmarks = bookmark_query.order_by(desc('time'))
page, per_page, offset = get_page_args()
bgstack15