mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-10 01:23:48 +01:00
Add admin option to set updateconfigs on all relevant packages
This commit is contained in:
parent
6b8b98c15b
commit
8fcea988ca
@ -26,7 +26,7 @@ from wtforms.validators import InputRequired, Length
|
||||
|
||||
from app.models import *
|
||||
from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
|
||||
from app.tasks.importtasks import importRepoScreenshot, checkZipRelease, importForeignDownloads
|
||||
from app.tasks.importtasks import importRepoScreenshot, checkZipRelease, importForeignDownloads, check_for_updates
|
||||
from app.utils import rank_required, addAuditLog, addNotification
|
||||
from . import bp
|
||||
|
||||
@ -175,6 +175,27 @@ def admin_page():
|
||||
flash("Deleted {} soft deleted packages packages".format(count), "success")
|
||||
return redirect(url_for("admin.admin_page"))
|
||||
|
||||
elif action == "addupdateconfig":
|
||||
for pkg in Package.query.filter(Package.repo != None, Package.releases.any(), Package.update_config == None).all():
|
||||
pkg.update_config = PackageUpdateConfig()
|
||||
|
||||
release: PackageRelease = pkg.releases.first()
|
||||
if release and release.commit_hash:
|
||||
pkg.update_config.last_commit = release.commit_hash
|
||||
|
||||
db.session.add(pkg.update_config)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
flash("Added update configs to packages", "success")
|
||||
return redirect(url_for("admin.admin_page"))
|
||||
|
||||
elif action == "runupdateconfig":
|
||||
check_for_updates.delay()
|
||||
|
||||
flash("Started update configs", "success")
|
||||
return redirect(url_for("admin.admin_page"))
|
||||
|
||||
else:
|
||||
flash("Unknown action: " + action, "danger")
|
||||
|
||||
|
@ -17,14 +17,14 @@
|
||||
|
||||
from celery import uuid
|
||||
from flask import *
|
||||
from flask_wtf import FlaskForm
|
||||
from flask_login import login_required
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import *
|
||||
from wtforms.ext.sqlalchemy.fields import QuerySelectField
|
||||
from wtforms.validators import *
|
||||
|
||||
from app.rediscache import has_key, set_key, make_download_key
|
||||
from app.tasks.importtasks import makeVCSRelease, checkZipRelease, updateMetaFromRelease, check_for_updates
|
||||
from app.tasks.importtasks import makeVCSRelease, checkZipRelease
|
||||
from app.utils import *
|
||||
from . import bp
|
||||
|
||||
@ -287,8 +287,6 @@ def update_config(package):
|
||||
package.update_config.ref = nonEmptyOrNone(form.ref.data)
|
||||
package.update_config.make_release = form.action.data == "make_release"
|
||||
|
||||
check_for_updates.delay()
|
||||
|
||||
db.session.commit()
|
||||
|
||||
if not form.disable.data and package.releases.count() == 0:
|
||||
|
@ -859,6 +859,7 @@ class PackageRelease(db.Model):
|
||||
|
||||
if self.package.update_config:
|
||||
self.package.update_config.outdated = False
|
||||
self.package.update_config.last_commit = self.commit_hash
|
||||
|
||||
return True
|
||||
|
||||
|
@ -323,9 +323,10 @@ def check_update_config(self, package_id):
|
||||
.replace("Cloning into '/tmp/", "Cloning into '") \
|
||||
.strip()
|
||||
|
||||
post_system_thread(package, "Failed to check git repository",
|
||||
"Error: {}.\n\nTask ID: {}" \
|
||||
.format(err, self.request.id))
|
||||
msg = "Error: {}.\n\nTask ID: {}\n\n[Change update configuration]({})" \
|
||||
.format(err, self.request.id, package.getUpdateConfigURL())
|
||||
|
||||
post_system_thread(package, "Failed to check git repository", msg)
|
||||
|
||||
db.session.commit()
|
||||
return
|
||||
@ -352,9 +353,14 @@ def check_update_config(self, package_id):
|
||||
elif not config.outdated:
|
||||
config.outdated = True
|
||||
|
||||
post_system_thread(package, "New commit detected, package outdated?",
|
||||
"Commit {} was detected on the Git repository.\n\n[Change update configuration]({})" \
|
||||
.format(hash[0:5], package.getUpdateConfigURL()))
|
||||
msg_last = ""
|
||||
if config.last_commit:
|
||||
msg_last = " The last commit was {}".format(config.last_commit[0:5])
|
||||
|
||||
msg = "New commit {} was found on the Git repository.{}\n\n[Change update configuration]({})" \
|
||||
.format(hash[0:5], msg_last, package.getUpdateConfigURL())
|
||||
|
||||
post_system_thread(package, "New commit detected, package may be outdated", msg)
|
||||
|
||||
config.last_commit = hash
|
||||
db.session.commit()
|
||||
|
@ -38,6 +38,8 @@
|
||||
<option value="importforeign">Import foreign release downloads</option>
|
||||
<option value="checkusers">Check forum users</option>
|
||||
<option value="importscreenshots">Import screenshots from VCS</option>
|
||||
<option value="addupdateconfig">Add update configs</option>
|
||||
<option value="runupdateconfig">Run update configs</option>
|
||||
</select>
|
||||
<input type="submit" value="Perform" class="col-sm-auto btn btn-primary ml-2" />
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user