From b2ac344c4bb4e2fed50a5e6925cdfef9c8cd041a Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 11 Jun 2022 00:03:48 +0100 Subject: make ui of tag filtering use radio buttons instead of links --- apioforum/forum.py | 3 +++ apioforum/templates/view_forum.html | 39 +++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/apioforum/forum.py b/apioforum/forum.py index 7f9b0b6..988c9a5 100644 --- a/apioforum/forum.py +++ b/apioforum/forum.py @@ -107,12 +107,15 @@ def view_forum(forum,page=1): avail_tags = get_avail_tags(forum['id']) tagfilter = request.args.get("tagfilter",None) + if tagfilter == "": + tagfilter = None tagfilter_clause = "" tagfilter_tag = None if tagfilter is not None: try: tagfilter = int(tagfilter) except ValueError: + flash(f'invalid tag id "{tagfilter}"') return redirect(url_for('forum.view_forum',forum_id=forum['id'])) else: # there is no risk of sql injection because diff --git a/apioforum/templates/view_forum.html b/apioforum/templates/view_forum.html index bac06e4..4cc5f5d 100644 --- a/apioforum/templates/view_forum.html +++ b/apioforum/templates/view_forum.html @@ -84,6 +84,7 @@ you do not have permission to create threads in this forum {% endif %} {% endmacro %} +
sorting and filtering options
+
- - {% if tagfilter_tag is not none %} - - {% endif %} - +

filter by tag:

+ + -{% if tagfilter_tag is none %} -

filter by tag: -{% for the_tag in avail_tags %} -{{tag(the_tag,href=url_for('forum.view_forum',forum_id=forum.id, - sortby=current_sortby,tagfilter=the_tag.id))}} + {% for the_tag in avail_tags %} +
+ + + {% endfor %} +

+ + + +

+ -{% else %} -(none available) -{% endfor %} -

-{% else %} -

only showing posts with the {{tag(tagfilter_tag)}} tag. - stop filtering -

-{% endif %}

-- cgit v1.2.3