Add import screenshots admin action

This commit is contained in:
rubenwardy 2018-05-15 20:05:35 +01:00
parent dbc56283eb
commit cfb92273ff
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
2 changed files with 11 additions and 1 deletions

@ -17,6 +17,7 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<select name="action">
<option value="importusers" selected>Create users from mod list</option>
<option value="importscreenshots">Import screenshots from VCS</option>
</select>
<input type="submit" value="Start" />
</form>

@ -3,6 +3,7 @@ from flask_user import *
from flask.ext import menu
from app import app
from app.models import *
from app.tasks.importtasks import importRepoScreenshot
from app.tasks.forumtasks import importUsersFromModList
from flask_wtf import FlaskForm
from wtforms import *
@ -18,6 +19,14 @@ def admin_page():
if action == "importusers":
task = importUsersFromModList.delay()
return redirect(url_for("check_task", id=task.id, r=url_for("user_list_page")))
elif action == "importscreenshots":
packages = Package.query \
.outerjoin(PackageScreenshot, Package.id==PackageScreenshot.package_id) \
.filter(PackageScreenshot.id==None).all()
for package in packages:
importRepoScreenshot.delay(package.id)
return redirect(url_for("admin_page"))
else:
flash("Unknown action: " + action, "error")