mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-10 01:23:48 +01:00
Use query builder in tag list, add link to todo page
This commit is contained in:
parent
c9e4638b34
commit
15bbc35e65
@ -64,10 +64,14 @@ def view():
|
||||
.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
|
||||
.count()
|
||||
|
||||
total_packages = Package.query.filter_by(approved=True, soft_deleted=False).count()
|
||||
total_to_tag = Package.query.filter_by(approved=True, soft_deleted=False, tags=None).count()
|
||||
|
||||
return render_template("todo/list.html", title="Reports and Work Queue",
|
||||
packages=packages, releases=releases, screenshots=screenshots,
|
||||
canApproveNew=canApproveNew, canApproveRel=canApproveRel, canApproveScn=canApproveScn,
|
||||
topics_to_add=topics_to_add, total_topics=total_topics)
|
||||
topics_to_add=topics_to_add, total_topics=total_topics, \
|
||||
total_packages=total_packages, total_to_tag=total_to_tag)
|
||||
|
||||
|
||||
@bp.route("/todo/topics/")
|
||||
@ -105,7 +109,10 @@ def topics():
|
||||
@bp.route("/todo/tags/")
|
||||
@login_required
|
||||
def tags():
|
||||
packages = Package.query.filter_by(approved=True, soft_deleted=False).all()
|
||||
qb = QueryBuilder(request.args)
|
||||
qb.setSortIfNone("score", "desc")
|
||||
query = qb.buildPackageQuery()
|
||||
|
||||
tags = Tag.query.order_by(db.asc(Tag.title)).all()
|
||||
|
||||
return render_template("todo/tags.html", packages=packages, tags=tags)
|
||||
return render_template("todo/tags.html", packages=query.all(), tags=tags)
|
||||
|
@ -36,7 +36,7 @@ class QueryBuilder:
|
||||
self.hide_nonfree = "nonfree" in hide_flags
|
||||
self.limit = 1 if self.lucky else None
|
||||
self.order_by = args.get("sort")
|
||||
self.order_dir = args.get("order") or "desc"
|
||||
self.order_dir = args.get("order") or "asc"
|
||||
|
||||
# Filters
|
||||
|
||||
@ -53,9 +53,10 @@ class QueryBuilder:
|
||||
if self.search is not None and self.search.strip() == "":
|
||||
self.search = None
|
||||
|
||||
def setSortIfNone(self, name):
|
||||
def setSortIfNone(self, name, dir="asc"):
|
||||
if self.order_by is None:
|
||||
self.order_by = name
|
||||
self.order_dir = dir
|
||||
|
||||
def getMinetestVersion(self):
|
||||
if not self.protocol_version and not self.minetest_version:
|
||||
|
@ -99,6 +99,22 @@
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<h2 class="mt-5">Tag Packages</h2>
|
||||
|
||||
<p>
|
||||
{{ total_to_tag }} / {{ total_packages }} packages don't have any tags.
|
||||
</p>
|
||||
|
||||
<div class="progress my-4">
|
||||
{% set perc = 100 * (total_packages - total_to_tag) / total_packages %}
|
||||
<div class="progress-bar bg-success" role="progressbar"
|
||||
style="width: {{ perc }}%" aria-valuenow="{{ perc }}" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
|
||||
<a class="btn btn-primary" href="{{ url_for('todo.tags') }}">View Tags</a>
|
||||
|
||||
|
||||
<h2 class="mt-5">Unadded Topic List</h2>
|
||||
|
||||
{% if total_topics > 0 %}
|
||||
@ -119,5 +135,4 @@
|
||||
The forum topic crawler needs to run at least once for this section to work.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
@ -36,9 +36,9 @@
|
||||
{% for tag in package.tags %}
|
||||
<span class="badge badge-primary mr-1">{{ tag.title }}</span>
|
||||
{% endfor %}
|
||||
<a class="badge badge-secondary add-btn px-2" href="#">
|
||||
<!-- <a class="badge badge-secondary add-btn px-2" href="#">
|
||||
<i class="fas fa-plus"></i>
|
||||
</a>
|
||||
</a> -->
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user