Allow any maintainer/editor to set up GitHub webhooks

This commit is contained in:
rubenwardy 2020-12-14 21:22:11 +00:00
parent c7aecd32be
commit 5cbdaae5b3
2 changed files with 7 additions and 5 deletions

@ -22,7 +22,7 @@ from flask import redirect, url_for, request, flash, abort, render_template, jso
from flask_login import current_user, login_required, login_user
from sqlalchemy import func, or_, and_
from app import github, csrf
from app.models import db, User, APIToken, Package, Permission, AuditSeverity
from app.models import db, User, APIToken, Package, Permission, AuditSeverity, UserRank
from app.utils import randomString, abs_url_for, addAuditLog
from app.blueprints.api.support import error, handleCreateRelease
import hmac, requests, json
@ -270,7 +270,9 @@ def handleMakeWebhook(gh_user, gh_repo, package, oauth, event, token):
return False
else:
flash("Failed to create webhook, received response from Github " +
str(r.status_code) + ": " +
str(r.json().get("message")), "danger")
import sys
print(r.text, file=sys.stderr)
message = str(r.status_code) + ": " + str(r.json().get("message"))
flash("Failed to create webhook, Github says: " + message, "danger")
return False

@ -7,7 +7,7 @@
{% block content %}
<p class="alert alert-info mb-4">
<a class="float-right btn btn-sm btn-info" href="{{ url_for('flatpage', path='help/release_webhooks') }}">{{ _("Learn more") }}</a>
{% if package.author == current_user and package.checkPerm(current_user, "APPROVE_RELEASE") and package.getIsOnGitHub() %}
{% if package.checkPerm(current_user, "APPROVE_RELEASE") and package.getIsOnGitHub() %}
<a class="float-right btn btn-sm btn-info mr-2" href="{{ url_for('github.setup_webhook', pid=package.id) }}">{{ _("Setup webhook") }}</a>
<i class="fas fa-info mr-2"></i>