From b07240c3738ac4a711a9a0d296f1661e0fb61de6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 21 2019 15:16:19 +0000 Subject: [PATCH 1/2] Move the endpoint to change the anitya status from patch to post Turns out otherwise the form does not validate properly with the version we have in production. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure_distgit/plugin.py b/pagure_distgit/plugin.py index b153b26..7ad6131 100644 --- a/pagure_distgit/plugin.py +++ b/pagure_distgit/plugin.py @@ -42,7 +42,7 @@ def anitya_get_endpoint(namespace, repo): return flask.jsonify(output) -@DISTGIT_NS.route("/anitya//", methods=["PATCH"]) +@DISTGIT_NS.route("/anitya//", methods=["POST"]) @api_login_required(acls=["modify_project"]) @api_method def anitya_patch_endpoint(namespace, repo): From 77a0ae107c8334d9ef1d5f02671d4fb4ab85ba36 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 21 2019 15:17:18 +0000 Subject: [PATCH 2/2] Don't override the repo variable with a PagureAnitya object Otherwise, when we call repo.name later on we crash since the PagureAnitya objects do not have such attribute. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure_distgit/plugin.py b/pagure_distgit/plugin.py index 7ad6131..6fec9df 100644 --- a/pagure_distgit/plugin.py +++ b/pagure_distgit/plugin.py @@ -71,11 +71,12 @@ def anitya_patch_endpoint(namespace, repo): try: if repo.anitya: repo.anitya.anitya_status = form.anitya_status.data + flask.g.session.add(repo) else: - repo = model.PagureAnitya( + mapping = model.PagureAnitya( project_id=repo.id, anitya_status=form.anitya_status.data ) - flask.g.session.add(repo) + flask.g.session.add(mapping) flask.g.session.commit() except SQLAlchemyError as err: # pragma: no cover flask.g.session.rollback()