From f29ffd84b68c0896eb0bf96214decf0e5945fcd5 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 03 2019 16:22:28 +0000 Subject: [PATCH 1/3] Small HTML fixes Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/themes/srcfpo/templates/repo_master_sidebar.html b/pagure/themes/srcfpo/templates/repo_master_sidebar.html index 34f43c3..5d31d3a 100644 --- a/pagure/themes/srcfpo/templates/repo_master_sidebar.html +++ b/pagure/themes/srcfpo/templates/repo_master_sidebar.html @@ -79,7 +79,7 @@
- +
No-Monitoring @@ -89,20 +89,20 @@
- +
- Monitoring + Monitoring
- +
- monitoring and scratch builds + monitoring and scratch builds
@@ -140,31 +140,31 @@ {% if g.authenticated %} $(".monitoring-menu a").click(function(){ - var selectedValue = $(this).attr('id'); - var _status = "no-monitoring"; - if (selectedValue === "monitoring_option_button") { - _status = "monitoring"; - } else if (selectedValue === "monitoring_and_scratch_option_button") { - _status = "monitoring-with-scratch" - } - - $.ajax({ - url: "{{ url_for('distgit_ns.anitya_patch_endpoint', repo=repo.name, namespace=repo.namespace) }}", - type: 'PATCH', - data: { - anitya_status: _status, - }, - dataType: 'json', - success: function(res) { - set_up_monitoring(res.monitoring) - }, - error: function() { - alert('Unable to change the monitoring status! ' + error); - } - }); + var selectedValue = $(this).attr('id'); + var _status = "no-monitoring"; + if (selectedValue === "monitoring_option_button") { + _status = "monitoring"; + } else if (selectedValue === "monitoring_and_scratch_option_button") { + _status = "monitoring-with-scratch" + } + $.ajax({ + url: "{{ url_for('distgit_ns.anitya_patch_endpoint', repo=repo.name, namespace=repo.namespace) }}", + type: 'PATCH', + data: { + anitya_status: _status, + }, + dataType: 'json', + success: function(res) { + set_up_monitoring(res.monitoring) + }, + error: function() { + alert('Unable to change the monitoring status! ' + error); + } + }); }); {% endif %} + }); {% endif %} From d822ca4b441cef0286ebed0bdaae847559c6c150 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 03 2019 16:23:27 +0000 Subject: [PATCH 2/3] Add a button to take maintenance of orphaned packages in dist-git --- diff --git a/pagure/themes/srcfpo/templates/repo_info.html b/pagure/themes/srcfpo/templates/repo_info.html index db713d7..c9d07aa 100644 --- a/pagure/themes/srcfpo/templates/repo_info.html +++ b/pagure/themes/srcfpo/templates/repo_info.html @@ -104,7 +104,8 @@
Created {{repo.date_created|humanize}}
diff --git a/pagure/themes/srcfpo/templates/repo_master_sidebar.html b/pagure/themes/srcfpo/templates/repo_master_sidebar.html index 5d31d3a..265946a 100644 --- a/pagure/themes/srcfpo/templates/repo_master_sidebar.html +++ b/pagure/themes/srcfpo/templates/repo_master_sidebar.html @@ -109,6 +109,21 @@
+ {% if g.authenticated and repo.user.user == "orphan" %} +
+
+

Orphaned:

+ +
+ {% endif %} + {% endif %} From 02088b2f58d60dfe1eefa2b5cadc0016430fb69d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 03 2019 16:23:27 +0000 Subject: [PATCH 3/3] Fix giving a project to someone who already had it Basically, if you give a project to someone else, they get added to the project. If you then take it over from them somehow (say on src.fp.o by taking it from the "orphan" user), you're being added again and this used to fail as pagure would say that you already have access. So we're splitting the action into two: 1/ give the project to the person it should be going to 2/ give that person access to the project. So if the step 2/ fails because the person already has access, at least the first step will have succeeded. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 06a7120..14d749c 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -3084,6 +3084,8 @@ def give_project(repo, username=None, namespace=None): flask.abort( 404, description="No such user %s found" % new_username ) + + failed = False try: old_main_admin = repo.user.user pagure.lib.query.set_project_owner( @@ -3092,25 +3094,14 @@ def give_project(repo, username=None, namespace=None): new_owner, required_groups=pagure_config.get("REQUIRED_GROUPS"), ) - # If the person doing the action is the former main admin, keep - # them as admins - if flask.g.fas_user.username == old_main_admin: - pagure.lib.query.add_user_to_project( - flask.g.session, - repo, - new_user=flask.g.fas_user.username, - user=flask.g.fas_user.username, - ) flask.g.session.commit() - pagure.lib.git.generate_gitolite_acls(project=repo) - flask.flash( - "The project has been transferred to %s" % new_username - ) except pagure.exceptions.PagureException as msg: + failed = True flask.g.session.rollback() _log.debug(msg) flask.flash(str(msg), "error") except SQLAlchemyError: # pragma: no cover + failed = True flask.g.session.rollback() flask.flash( "Due to a database error, this project could not be " @@ -3118,6 +3109,34 @@ def give_project(repo, username=None, namespace=None): "error", ) + if not failed: + try: + # If the person doing the action is the former main admin, keep + # them as admins + if flask.g.fas_user.username == old_main_admin: + pagure.lib.query.add_user_to_project( + flask.g.session, + repo, + new_user=flask.g.fas_user.username, + user=flask.g.fas_user.username, + ) + flask.g.session.commit() + except pagure.exceptions.PagureException as msg: + flask.g.session.rollback() + _log.debug(msg) + except SQLAlchemyError: # pragma: no cover + flask.g.session.rollback() + flask.flash( + "Due to a database error, this access could not be " + "entirely set.", + "error", + ) + + pagure.lib.git.generate_gitolite_acls(project=repo) + flask.flash( + "The project has been transferred to %s" % new_username + ) + return flask.redirect( flask.url_for( "ui_ns.view_repo",