From 72ad3c0d048c0a6bcd6a6a889a95195a53906e63 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sat, 13 Aug 2016 15:35:36 +0200 Subject: [PATCH] Total amount of tags, number of bookmarks per tag --- digimarks.py | 6 ++++-- templates/tags.html | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/digimarks.py b/digimarks.py index b07d048..85a4322 100644 --- a/digimarks.py +++ b/digimarks.py @@ -422,9 +422,11 @@ def tags(userkey): publictag = PublicTag.get(PublicTag.userkey == userkey, PublicTag.tag == tag) except PublicTag.DoesNotExist: publictag = None - total = 'n/a' # TODO: count number of bookmarks with this tag + + total = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.tags.contains(tag), Bookmark.status == Bookmark.VISIBLE).count() alltags.append({'tag': tag, 'publictag': publictag, 'total': total}) - return render_template('tags.html', tags=alltags, userkey=userkey) + total = len(alltags) + return render_template('tags.html', tags=alltags, total=total, userkey=userkey) @app.route('//tag/') diff --git a/templates/tags.html b/templates/tags.html index 409b0be..b28d32e 100644 --- a/templates/tags.html +++ b/templates/tags.html @@ -14,6 +14,16 @@ + + + All + + + - + + {{ total }} + + {% for tag in tags %} @@ -27,6 +37,7 @@ {% endif %} + {{ tag['total'] }} {% endfor %}