Add 'set provides from name' admin action

This commit is contained in:
rubenwardy 2018-05-27 23:13:13 +01:00
parent d0969263ba
commit a2b873bf38
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
2 changed files with 13 additions and 2 deletions

@ -18,8 +18,9 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<select name="action">
<option value="importusers">Create users from mod list</option>
<option value="importscreenshots">Import screenshots from VCS</option>
<option value="importdepends" selected>Import dependencies from downloads</option>
<option value="importscreenshots" selected>Import screenshots from VCS</option>
<option value="importdepends">Import dependencies from downloads</option>
<option value="modprovides">Set provides to mod name</option>
</select>
<input type="submit" value="Perform" />
</form>

@ -55,6 +55,16 @@ def admin_page():
elif action == "importdepends":
task = importAllDependencies.delay()
return redirect(url_for("check_task", id=task.id, r=url_for("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_page"))
else:
flash("Unknown action: " + action, "error")