Fix release auto-approval

This commit is contained in:
rubenwardy 2019-03-29 20:47:48 +00:00
parent 2677e088a8
commit 93a74b7681
3 changed files with 12 additions and 2 deletions

@ -696,6 +696,15 @@ class PackageRelease(db.Model):
def __init__(self):
self.releaseDate = datetime.datetime.now()
def approve(self, user):
if not self.package.checkPerm(user, Permission.APPROVE_RELEASE):
return False
assert(self.task_id is None and self.url is not None and self.url != "")
self.approved = True
return True
class PackageReview(db.Model):
id = db.Column(db.Integer, primary_key=True)

@ -348,6 +348,7 @@ def makeVCSReleaseFromGithub(id, branch, release, url):
release.url = urlmaker.getCommitDownload(commits[0]["sha"])
release.task_id = None
release.commit_hash = commits[0]["sha"]
release.approve(release.package.author)
print(release.url)
db.session.commit()
@ -379,6 +380,7 @@ def makeVCSRelease(id, branch):
release.url = "/uploads/" + filename
release.task_id = None
release.commit_hash = repo.head.object.hexsha
release.approve(release.package.author)
print(release.url)
db.session.commit()

@ -85,7 +85,6 @@ def create_release_page(package):
rel.task_id = uuid()
rel.min_rel = form["min_rel"].data.getActual()
rel.max_rel = form["max_rel"].data.getActual()
rel.approved = package.checkPerm(current_user, Permission.APPROVE_RELEASE)
db.session.add(rel)
db.session.commit()
@ -105,7 +104,7 @@ def create_release_page(package):
rel.url = uploadedPath
rel.min_rel = form["min_rel"].data.getActual()
rel.max_rel = form["max_rel"].data.getActual()
rel.approved = package.checkPerm(current_user, Permission.APPROVE_RELEASE)
rel.approve(current_user)
db.session.add(rel)
db.session.commit()