def packageReleaseDeletePost(packageId, packageReleaseId): if g.currentUser is None: return api.jsonMissingActionPermissionFailure("delete package releases") packageRelease = PackageRelease.getById(g.databaseSession, packageReleaseId) package = packageRelease.package if packageRelease is None: return api.jsonFailure("The package release does not exist or has been deleted.") if not g.currentUser.canEditPackage(package): return api.jsonMissingActionPermissionFailure("delete package releases") packageRelease.remove(g.databaseSession) g.databaseSession.commit() return { "success": True }
def packageReleaseDownload(packageId, packageReleaseId): packageRelease = PackageRelease.getById(g.databaseSession, packageReleaseId) if packageRelease is None: flask.abort(404) response = flask.send_file(packageRelease.generatePackage(g.databaseSession), as_attachment = True, attachment_filename = packageRelease.getFullFileName(), conditional = True) return response
def packageReleaseJson(packageId, packageReleaseId, type): packageRelease = PackageRelease.getById(g.databaseSession, packageReleaseId) if packageRelease is None: return None return packageRelease.toDictionaryRecursive(g.currentUser == packageRelease.package.creatorUser)