mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-14 03:23:46 +01:00
Redesign todo page, add ability to Approve All screenshots
This commit is contained in:
parent
896a65fd99
commit
0fd4984e5a
@ -5,43 +5,33 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Awaiting Approval</h2>
|
<h2 class="mb-4">Approval Queue</h2>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
{% if canApproveNew and packages %}
|
{% if canApproveNew and packages %}
|
||||||
<h3>Packages</h3>
|
<div class="col-sm-6">
|
||||||
<ul>
|
<div class="card">
|
||||||
|
<h3 class="card-header">Packages</h3>
|
||||||
|
<div class="list-group list-group-flush">
|
||||||
{% for p in packages %}
|
{% for p in packages %}
|
||||||
<li><a href="{{ p.getDetailsURL() }}">
|
<a href="{{ p.getDetailsURL() }}" class="list-group-item list-group-item-action">
|
||||||
{{ p.title }} by {{ p.author.display_name }}
|
{{ p.title }} by {{ p.author.display_name }}
|
||||||
</a></li>
|
|
||||||
{% else %}
|
|
||||||
<li><i>No packages need reviewing.</i></ul>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if canApproveScn and screenshots %}
|
|
||||||
<h3>Screenshots</h3>
|
|
||||||
<ul>
|
|
||||||
{% for s in screenshots %}
|
|
||||||
<li>
|
|
||||||
<a href="{{ s.getEditURL() }}">{{ s.title }}</a>
|
|
||||||
on
|
|
||||||
<a href="{{ s.package.getDetailsURL() }}">
|
|
||||||
{{ s.package.title }} by {{ s.package.author.display_name }}
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><i>No screenshots need reviewing.</i></ul>
|
<li class="list-group-item"><i>No packages need reviewing.</i></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if canApproveRel and releases %}
|
{% if canApproveRel and releases %}
|
||||||
<h3>Releases</h3>
|
<div class="col-sm-6">
|
||||||
<ul>
|
<div class="card">
|
||||||
|
<h3 class="card-header">Releases</h3>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
{% for r in releases %}
|
{% for r in releases %}
|
||||||
<li>
|
<li class="list-group-item">
|
||||||
<a href="{{ r.getEditURL() }}">{{ r.title }}</a>
|
<a href="{{ r.getEditURL() }}">{{ r.title }}</a>
|
||||||
on
|
on
|
||||||
<a href="{{ r.package.getDetailsURL() }}">
|
<a href="{{ r.package.getDetailsURL() }}">
|
||||||
@ -49,9 +39,45 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><i>No releases need reviewing.</i></ul>
|
<li class="list-group-item"><i>No releases need reviewing.</i></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if canApproveScn and screenshots %}
|
||||||
|
<div class="card my-4">
|
||||||
|
<h3 class="card-header">Screenshots
|
||||||
|
<form class="float-right" method="post" action="{{ url_for('todo_page') }}">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||||
|
<input type="hidden" name="action" value="screenshots_approve_all" />
|
||||||
|
<input class="btn btn-sm btn-primary" type="submit" value="Approve All" />
|
||||||
|
</form>
|
||||||
|
</h3>
|
||||||
|
<ul class="card-body d-flex p-0 flex-row flex-wrap justify-content-start align-content-start p-4">
|
||||||
|
{% for s in screenshots %}
|
||||||
|
<li class="packagetile flex-fill"><a href="{{ s.getEditURL() }}"
|
||||||
|
style="background-image: url({{ s.getThumbnailURL(3) or '/static/placeholder.png' }});">
|
||||||
|
<div class="packagegridscrub"></div>
|
||||||
|
<div class="packagegridinfo">
|
||||||
|
<h3>
|
||||||
|
{{ s.title }}
|
||||||
|
<br />
|
||||||
|
<small>{{ s.package.title }} by {{ s.package.author.display_name }}</small>
|
||||||
|
</h3>
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li><i>No screenshots need reviewing.</i></li>
|
||||||
|
{% endfor %}
|
||||||
|
{% for i in range(4) %}
|
||||||
|
<li class="packagetile flex-fill"></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if not (packages or screenshots or releases) %}
|
{% if not (packages or screenshots or releases) %}
|
||||||
@ -63,8 +89,16 @@
|
|||||||
<h2>Unadded Topic List</h2>
|
<h2>Unadded Topic List</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
There are
|
{{ total_topics - topics_to_add }} / {{ total_topics }} packages have been been added to cdb,
|
||||||
<a href="{{ url_for('todo_topics_page') }}">{{ topics_to_add }} packages</a>
|
based on cdb's forum parser. {{ topics_to_add }} remaining.
|
||||||
to be added to cdb, based on cdb's forum parser.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<div class="progress my-4">
|
||||||
|
{% set perc = 32 %}
|
||||||
|
<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_topics_page') }}">View Unadded Topic List</a>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -22,7 +22,7 @@ from app import app
|
|||||||
from app.models import *
|
from app.models import *
|
||||||
from app.querybuilder import QueryBuilder
|
from app.querybuilder import QueryBuilder
|
||||||
|
|
||||||
@app.route("/todo/")
|
@app.route("/todo/", methods=["GET", "POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def todo_page():
|
def todo_page():
|
||||||
canApproveNew = Permission.APPROVE_NEW.check(current_user)
|
canApproveNew = Permission.APPROVE_NEW.check(current_user)
|
||||||
@ -41,16 +41,32 @@ def todo_page():
|
|||||||
if canApproveScn:
|
if canApproveScn:
|
||||||
screenshots = PackageScreenshot.query.filter_by(approved=False).all()
|
screenshots = PackageScreenshot.query.filter_by(approved=False).all()
|
||||||
|
|
||||||
|
if not canApproveNew and not canApproveRel and not canApproveScn:
|
||||||
|
abort(403)
|
||||||
|
|
||||||
topics_to_add = ForumTopic.query \
|
if request.method == "POST":
|
||||||
|
if request.form["action"] == "screenshots_approve_all":
|
||||||
|
if not canApproveScn:
|
||||||
|
abort(403)
|
||||||
|
|
||||||
|
PackageScreenshot.query.update({ "approved": True })
|
||||||
|
db.session.commit()
|
||||||
|
return redirect(url_for("todo_page"))
|
||||||
|
else:
|
||||||
|
abort(400)
|
||||||
|
|
||||||
|
topic_query = ForumTopic.query \
|
||||||
|
.filter_by(discarded=False)
|
||||||
|
|
||||||
|
total_topics = topic_query.count()
|
||||||
|
topics_to_add = topic_query \
|
||||||
.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
|
.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
|
||||||
.filter_by(discarded=False) \
|
|
||||||
.count()
|
.count()
|
||||||
|
|
||||||
return render_template("todo/list.html", title="Reports and Work Queue",
|
return render_template("todo/list.html", title="Reports and Work Queue",
|
||||||
packages=packages, releases=releases, screenshots=screenshots,
|
packages=packages, releases=releases, screenshots=screenshots,
|
||||||
canApproveNew=canApproveNew, canApproveRel=canApproveRel, canApproveScn=canApproveScn,
|
canApproveNew=canApproveNew, canApproveRel=canApproveRel, canApproveScn=canApproveScn,
|
||||||
topics_to_add=topics_to_add)
|
topics_to_add=topics_to_add, total_topics=total_topics)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/todo/topics/")
|
@app.route("/todo/topics/")
|
||||||
@ -62,7 +78,7 @@ def todo_topics_page():
|
|||||||
|
|
||||||
tmp_q = ForumTopic.query
|
tmp_q = ForumTopic.query
|
||||||
if not qb.show_discarded:
|
if not qb.show_discarded:
|
||||||
tmp_q = tmp_q.filter_by(discarded=qb.show_discarded)
|
tmp_q = tmp_q.filter_by(discarded=False)
|
||||||
total = tmp_q.count()
|
total = tmp_q.count()
|
||||||
topic_count = query.count()
|
topic_count = query.count()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user