mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 14:32:25 +01:00
Improve admin list design
This commit is contained in:
parent
a123f42291
commit
d7ecf8041a
@ -33,10 +33,12 @@ import datetime, os
|
|||||||
def admin_page():
|
def admin_page():
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
action = request.form["action"]
|
action = request.form["action"]
|
||||||
|
|
||||||
if action == "delstuckreleases":
|
if action == "delstuckreleases":
|
||||||
PackageRelease.query.filter(PackageRelease.task_id != None).delete()
|
PackageRelease.query.filter(PackageRelease.task_id != None).delete()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(url_for("admin.admin_page"))
|
return redirect(url_for("admin.admin_page"))
|
||||||
|
|
||||||
elif action == "checkreleases":
|
elif action == "checkreleases":
|
||||||
releases = PackageRelease.query.filter(PackageRelease.url.like("/uploads/%")).all()
|
releases = PackageRelease.query.filter(PackageRelease.url.like("/uploads/%")).all()
|
||||||
|
|
||||||
@ -52,6 +54,7 @@ def admin_page():
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
return redirect(url_for("todo.view"))
|
return redirect(url_for("todo.view"))
|
||||||
|
|
||||||
elif action == "reimportpackages":
|
elif action == "reimportpackages":
|
||||||
tasks = []
|
tasks = []
|
||||||
for package in Package.query.filter_by(approved=True, soft_deleted=False).all():
|
for package in Package.query.filter_by(approved=True, soft_deleted=False).all():
|
||||||
@ -67,12 +70,15 @@ def admin_page():
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
return redirect(url_for("todo.view"))
|
return redirect(url_for("todo.view"))
|
||||||
|
|
||||||
elif action == "importmodlist":
|
elif action == "importmodlist":
|
||||||
task = importTopicList.delay()
|
task = importTopicList.delay()
|
||||||
return redirect(url_for("tasks.check", id=task.id, r=url_for("todo.topics")))
|
return redirect(url_for("tasks.check", id=task.id, r=url_for("todo.topics")))
|
||||||
|
|
||||||
elif action == "checkusers":
|
elif action == "checkusers":
|
||||||
task = checkAllForumAccounts.delay()
|
task = checkAllForumAccounts.delay()
|
||||||
return redirect(url_for("tasks.check", id=task.id, r=url_for("admin.admin_page")))
|
return redirect(url_for("tasks.check", id=task.id, r=url_for("admin.admin_page")))
|
||||||
|
|
||||||
elif action == "importscreenshots":
|
elif action == "importscreenshots":
|
||||||
packages = Package.query \
|
packages = Package.query \
|
||||||
.filter_by(soft_deleted=False) \
|
.filter_by(soft_deleted=False) \
|
||||||
@ -83,6 +89,7 @@ def admin_page():
|
|||||||
importRepoScreenshot.delay(package.id)
|
importRepoScreenshot.delay(package.id)
|
||||||
|
|
||||||
return redirect(url_for("admin.admin_page"))
|
return redirect(url_for("admin.admin_page"))
|
||||||
|
|
||||||
elif action == "restore":
|
elif action == "restore":
|
||||||
package = Package.query.get(request.form["package"])
|
package = Package.query.get(request.form["package"])
|
||||||
if package is None:
|
if package is None:
|
||||||
@ -91,40 +98,13 @@ def admin_page():
|
|||||||
package.soft_deleted = False
|
package.soft_deleted = False
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(url_for("admin.admin_page"))
|
return redirect(url_for("admin.admin_page"))
|
||||||
elif action == "modprovides":
|
|
||||||
packages = Package.query.filter_by(type=PackageType.MOD).all()
|
|
||||||
mpackage_cache = {}
|
|
||||||
for p in packages:
|
|
||||||
if len(p.provides) == 0:
|
|
||||||
p.provides.append(MetaPackage.GetOrCreate(p.name, mpackage_cache))
|
|
||||||
|
|
||||||
db.session.commit()
|
|
||||||
return redirect(url_for("admin.admin_page"))
|
|
||||||
elif action == "recalcscores":
|
elif action == "recalcscores":
|
||||||
for p in Package.query.all():
|
for p in Package.query.all():
|
||||||
p.recalcScore()
|
p.recalcScore()
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(url_for("admin.admin_page"))
|
return redirect(url_for("admin.admin_page"))
|
||||||
elif action == "vcsrelease":
|
|
||||||
for package in Package.query.filter(Package.repo.isnot(None)).all():
|
|
||||||
if package.releases.count() != 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
rel = PackageRelease()
|
|
||||||
rel.package = package
|
|
||||||
rel.title = datetime.date.today().isoformat()
|
|
||||||
rel.url = ""
|
|
||||||
rel.task_id = uuid()
|
|
||||||
rel.approved = True
|
|
||||||
db.session.add(rel)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
makeVCSRelease.apply_async((rel.id, "master"), task_id=rel.task_id)
|
|
||||||
|
|
||||||
msg = "Release {} created".format(rel.title)
|
|
||||||
addNotification(package.maintainers, current_user, msg, rel.getEditURL(), package)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
elif action == "cleanuploads":
|
elif action == "cleanuploads":
|
||||||
upload_dir = app.config['UPLOAD_DIR']
|
upload_dir = app.config['UPLOAD_DIR']
|
||||||
|
@ -5,48 +5,55 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<ul>
|
<div class="row">
|
||||||
<li><a href="{{ url_for('users.list_all') }}">User list</a></li>
|
<div class="col-md-6">
|
||||||
<li><a href="{{ url_for('admin.tag_list') }}">Tag Editor</a></li>
|
<div class="list-group">
|
||||||
<li><a href="{{ url_for('admin.license_list') }}">License Editor</a></li>
|
<a class="list-group-item list-group-item-action" href="{{ url_for('users.list_all') }}">User list</a>
|
||||||
<li><a href="{{ url_for('admin.version_list') }}">Version Editor</a></li>
|
<a class="list-group-item list-group-item-action" href="{{ url_for('admin.tag_list') }}">Tag Editor</a>
|
||||||
<li><a href="{{ url_for('admin.switch_user') }}">Sign in as another user</a></li>
|
<a class="list-group-item list-group-item-action" href="{{ url_for('admin.license_list') }}">License Editor</a>
|
||||||
</ul>
|
<a class="list-group-item list-group-item-action" href="{{ url_for('admin.version_list') }}">Version Editor</a>
|
||||||
|
<a class="list-group-item list-group-item-action" href="{{ url_for('admin.switch_user') }}">Sign in as another user</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card my-4">
|
<div class="col-md-6">
|
||||||
<h2 class="card-header">Do action</h2>
|
<div class="card mb-4">
|
||||||
|
<h2 class="card-header">Do action</h2>
|
||||||
|
|
||||||
<form method="post" action="" class="card-body">
|
<form method="post" action="" class="card-body">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||||
<select name="action">
|
<div class="row px-3">
|
||||||
<option value="delstuckreleases" selected>Delete stuck releases</option>
|
<select name="action" class="custom-select col">
|
||||||
<option value="checkreleases">Validate all Zip releases</option>
|
<option value="delstuckreleases" selected>Delete stuck releases</option>
|
||||||
<option value="reimportpackages">Reimport meta</option>
|
<option value="checkreleases">Validate all Zip releases</option>
|
||||||
<option value="importmodlist">Import forum topics</option>
|
<option value="reimportpackages">Reimport meta</option>
|
||||||
<option value="recalcscores">Recalculate package scores</option>
|
<option value="importmodlist">Import forum topics</option>
|
||||||
<option value="checkusers">Check forum users</option>
|
<option value="recalcscores">Recalculate package scores</option>
|
||||||
<option value="importscreenshots">Import screenshots from VCS</option>
|
<option value="checkusers">Check forum users</option>
|
||||||
<option value="cleanuploads">Delete unreachable uploads</option>
|
<option value="importscreenshots">Import screenshots from VCS</option>
|
||||||
<!-- <option value="importdepends">Import dependencies from downloads</option> -->
|
<option value="cleanuploads">Delete unreachable uploads</option>
|
||||||
<!-- <option value="modprovides">Set provides to mod name</option> -->
|
</select>
|
||||||
<!-- <option value="vcsrelease">Create VCS releases</option> -->
|
<input type="submit" value="Perform" class="col-sm-auto btn btn-primary ml-2" />
|
||||||
</select>
|
</div>
|
||||||
<input type="submit" value="Perform" />
|
</form>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card my-4">
|
<div class="card">
|
||||||
<h2 class="card-header">Restore Package</h2>
|
<h2 class="card-header">Restore Package</h2>
|
||||||
|
|
||||||
<form method="post" action="" class="card-body">
|
<form method="post" action="" class="card-body">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||||
<input type="hidden" name="action" value="restore" />
|
<input type="hidden" name="action" value="restore" />
|
||||||
<select name="package">
|
<div class="row px-3">
|
||||||
{% for p in deleted_packages %}
|
<select name="package" class="custom-select col">
|
||||||
<option value={{ p.id }}>{{ p.id}}) {{ p.title }} by {{ p.author.display_name }}</option>
|
{% for p in deleted_packages %}
|
||||||
{% endfor %}
|
<option value={{ p.id }}>{{ p.id}}) {{ p.title }} by {{ p.author.display_name }}</option>
|
||||||
</select>
|
{% endfor %}
|
||||||
<input type="submit" value="Restore" />
|
</select>
|
||||||
</form>
|
<input type="submit" value="Restore" class="col-sm-auto btn btn-primary ml-2" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2 class="mt-4">Unadded Topic List</h2>
|
<h2 class="mt-5">Unadded Topic List</h2>
|
||||||
|
|
||||||
{% if total_topics > 0 %}
|
{% if total_topics > 0 %}
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
Reference in New Issue
Block a user