Add ability to filter by no tags on package tags page

This commit is contained in:
rubenwardy 2021-02-05 16:57:40 +00:00
parent 3839dfbf90
commit 7ff92bc7c1
2 changed files with 17 additions and 3 deletions

View File

@ -117,9 +117,14 @@ def tags():
qb.setSortIfNone("score", "desc") qb.setSortIfNone("score", "desc")
query = qb.buildPackageQuery() query = qb.buildPackageQuery()
only_no_tags = isYes(request.args.get("no_tags"))
if only_no_tags:
query = query.filter(Package.tags==None)
tags = Tag.query.order_by(db.asc(Tag.title)).all() tags = Tag.query.order_by(db.asc(Tag.title)).all()
return render_template("todo/tags.html", current_tab="tags", packages=query.all(), tags=tags) return render_template("todo/tags.html", current_tab="tags", packages=query.all(), \
tags=tags, only_no_tags=only_no_tags)
@bp.route("/user/tags/") @bp.route("/user/tags/")

View File

@ -18,13 +18,22 @@
</form> </form>
</div> </div>
<div class="col-md-6 text-right"> <div class="col-md-6 text-right">
{% if only_no_tags %}
<a class="btn btn-primary" href="{{ url_set_query(no_tags=0) }}">
{{ _("Missing tags only") }}
</a>
{% else %}
<a class="btn btn-secondary" href="{{ url_set_query(no_tags=1) }}">
{{ _("Missing tags only") }}
</a>
{% endif %}
{% if check_global_perm(current_user, "EDIT_TAGS") %} {% if check_global_perm(current_user, "EDIT_TAGS") %}
<a class="btn btn-secondary" href="{{ url_for('admin.tag_list') }}">{{ _("Edit Tags") }}</a> <a class="btn btn-secondary ml-2" href="{{ url_for('admin.tag_list') }}">{{ _("Edit Tags") }}</a>
{% endif %} {% endif %}
</div> </div>
</div> </div>
<table class="table mt-t"> <table class="table mt-5">
<tr> <tr>
<th>Package</th> <th>Package</th>
<th></th> <th></th>