~comcloudway/builds.sr.ht

c2bdab5b752d0700fd8c3d6a8849b4427d2994be — Conrad Hoffmann 11 months ago 468badf
Un-break "View manifest" link in UI

This link was using the previously unauthenticated API endpoint for
manifests. However, that now requires authentication like any other
endpoint. Instead, provide a simple UI route which displays the
manifest.
2 files changed, 15 insertions(+), 1 deletions(-)

M buildsrht/blueprints/jobs.py
M buildsrht/templates/job.html
M buildsrht/blueprints/jobs.py => buildsrht/blueprints/jobs.py +14 -0
@@ 510,3 510,17 @@ def job_by_id(username, job_id):
            sort_tasks=lambda tasks: sorted(tasks, key=lambda t: t.id),
            min_artifact_date=min_artifact_date,
            payment_required=payment_required)

@jobs.route("/~<username>/job/<int:job_id>/manifest")
def manifest_by_job_id(username, job_id):
    user = User.query.filter(User.username == username).first()
    if not user:
        abort(404)
    job = Job.query.options(sa.orm.joinedload(Job.tasks)).get(job_id)
    if not job:
        abort(404)
    if not get_access(job):
        abort(404)
    if job.owner_id != user.id:
        abort(404)
    return Response(job.manifest, mimetype="text/plain")

M buildsrht/templates/job.html => buildsrht/templates/job.html +1 -1
@@ 69,7 69,7 @@
        <dt>Updated</dt>
        <dd>{{ job.updated | date }}</dd>
        <dt>Build manifest</dt>
        <dd><a href="/api/jobs/{{ job.id }}/manifest">view manifest »</a></dd>
	<dd><a href="/~{{ job.owner.username }}/job/{{ job.id }}/manifest">view manifest »</a></dd>
      </dl>
      {% if current_user and job.status.value in [
        "success", "failed", "timeout", "cancelled"