diff options
-rw-r--r-- | apioforum/forum.py | 3 | ||||
-rw-r--r-- | 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 %} + <details {%- if current_sortby != "ad" or tagfilter_tag is not none %} open @@ -91,6 +92,7 @@ you do not have permission to create threads in this forum <summary>sorting and filtering options</summary> <form class="inline-form small-form" method="get"> + <fieldset> <label for="sortby">sort threads by</label> <select name="sortby"> {{ sortby_option("ad", "last activity (newest first)") }} @@ -98,27 +100,26 @@ you do not have permission to create threads in this forum {{ sortby_option("cd", "creation time (newest first)") }} {{ sortby_option("ca", "creation time (oldest first)") }} </select> - <input type="submit" value="go"> - {% if tagfilter_tag is not none %} - <input type="hidden" name="tagfilter" value="{{tagfilter_tag.id}}"> - {% endif %} -</form> + <p>filter by tag:</p> + <input {% if tagfilter_tag is none %}checked{% endif %} type=radio id=tagfilter-none name=tagfilter value=""> + <label for=tagfilter-none>don't</label> -{% if tagfilter_tag is none %} -<p>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 %} + <br> + <input type="radio" id="tagfilter-{{the_tag.id}}" + name="tagfilter" value="{{the_tag.id}}" + {% if tagfilter_tag.id == the_tag.id %}checked{% endif %}> + <label for="tagfilter-{{the_tag.id}}"> + {{tag(the_tag)}} + </label> + {% endfor %} + <br><br> + + + <input type="submit" value="apply"> + </fieldset> +</form> -{% else %} -<em>(none available)</em> -{% endfor %} -</p> -{% else %} -<p>only showing posts with the {{tag(tagfilter_tag)}} tag. -<a href="{{url_for('forum.view_forum',forum_id=forum.id,sortby=current_sortby)}}"> stop filtering</a> -</p> -{% endif %} </details> </p> |