mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 19:57:29 +01:00
Add admin option to check all releases
This commit is contained in:
parent
facdd35b11
commit
6e626c0f89
@ -20,8 +20,8 @@ from flask_user import *
|
||||
import flask_menu as menu
|
||||
from . import bp
|
||||
from app.models import *
|
||||
from celery import uuid
|
||||
from app.tasks.importtasks import importRepoScreenshot, importAllDependencies, makeVCSRelease
|
||||
from celery import uuid, group
|
||||
from app.tasks.importtasks import importRepoScreenshot, importAllDependencies, makeVCSRelease, checkZipRelease
|
||||
from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import *
|
||||
@ -37,6 +37,21 @@ def admin_page():
|
||||
PackageRelease.query.filter(PackageRelease.task_id != None).delete()
|
||||
db.session.commit()
|
||||
return redirect(url_for("admin.admin_page"))
|
||||
elif action == "checkreleases":
|
||||
releases = PackageRelease.query.filter(PackageRelease.url.like("/uploads/%")).all()
|
||||
|
||||
tasks = []
|
||||
for release in releases:
|
||||
zippath = release.url.replace("/uploads/", app.config["UPLOAD_DIR"])
|
||||
tasks.append(checkZipRelease.s(release.id, zippath))
|
||||
|
||||
result = group(tasks).apply_async()
|
||||
|
||||
while not result.ready():
|
||||
import time
|
||||
time.sleep(0.1)
|
||||
|
||||
return redirect(url_for("todo.view"))
|
||||
elif action == "importmodlist":
|
||||
task = importTopicList.delay()
|
||||
return redirect(url_for("tasks.check", id=task.id, r=url_for("todo.topics")))
|
||||
|
@ -22,7 +22,7 @@ from . import bp
|
||||
|
||||
from app.rediscache import has_key, set_key, make_download_key
|
||||
from app.models import *
|
||||
from app.tasks.importtasks import makeVCSRelease, checkZIPRelease
|
||||
from app.tasks.importtasks import makeVCSRelease, checkZipRelease
|
||||
from app.utils import *
|
||||
|
||||
from celery import uuid
|
||||
@ -110,7 +110,7 @@ def create_release(package):
|
||||
db.session.add(rel)
|
||||
db.session.commit()
|
||||
|
||||
checkZIPRelease.apply_async((rel.id, uploadedPath), task_id=rel.task_id)
|
||||
checkZipRelease.apply_async((rel.id, uploadedPath), task_id=rel.task_id)
|
||||
|
||||
msg = "{}: Release {} created".format(package.title, rel.title)
|
||||
triggerNotif(package.author, current_user, msg, rel.getEditURL())
|
||||
|
@ -229,8 +229,8 @@ def makeVCSReleaseFromGithub(id, branch, release, url):
|
||||
return release.url
|
||||
|
||||
|
||||
@celery.task()
|
||||
def checkZIPRelease(id, path):
|
||||
@celery.task(bind=True)
|
||||
def checkZipRelease(self, id, path):
|
||||
release = PackageRelease.query.get(id)
|
||||
if release is None:
|
||||
raise TaskError("No such release!")
|
||||
@ -246,6 +246,13 @@ def checkZIPRelease(id, path):
|
||||
tree = build_tree(temp, expected_type=ContentType[release.package.type.name], \
|
||||
author=release.package.author.username, name=release.package.name)
|
||||
except MinetestCheckError as err:
|
||||
if "Fails validation" not in release.title:
|
||||
release.title += " (Fails validation)"
|
||||
|
||||
release.task_id = self.request.id
|
||||
release.approved = False
|
||||
db.session.commit()
|
||||
|
||||
raise TaskError(str(err))
|
||||
|
||||
release.task_id = None
|
||||
|
@ -20,6 +20,7 @@
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<select name="action">
|
||||
<option value="delstuckreleases" selected>Delete stuck releases</option>
|
||||
<option value="checkreleases">Validate all Zip releases</option>
|
||||
<option value="importmodlist">Import forum topics</option>
|
||||
<option value="recalcscores">Recalculate package scores</option>
|
||||
<option value="checkusers">Check forum users</option>
|
||||
|
@ -12,12 +12,12 @@ GitHub-Flask~=3.2
|
||||
SQLAlchemy-Searchable==1.0.3
|
||||
|
||||
beautifulsoup4~=4.6
|
||||
celery==4.1.1
|
||||
kombu==4.2.0
|
||||
celery~=4.4
|
||||
kombu~=4.6
|
||||
GitPython~=2.1
|
||||
git-archive-all~=1.20
|
||||
lxml~=4.2
|
||||
pillow~=6.2
|
||||
pyScss~=1.3
|
||||
redis==2.10.6
|
||||
redis~=3.3
|
||||
psycopg2~=2.7
|
||||
|
Loading…
Reference in New Issue
Block a user