You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/04/01 00:35:54 UTC
[2/2] allura git commit: [#7865] add per-tool option to disable
one-click merging
[#7865] add per-tool option to disable one-click merging
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/7f451eeb
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/7f451eeb
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/7f451eeb
Branch: refs/heads/db/7865
Commit: 7f451eeb81942db9296585b905696ce03cfdc522
Parents: 8a8343c
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Mar 31 18:35:31 2015 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Tue Mar 31 18:35:31 2015 -0400
----------------------------------------------------------------------
Allura/allura/lib/repository.py | 23 +++++++++++++++++----
Allura/allura/model/repository.py | 2 ++
Allura/allura/templates/repo/checkout_url.html | 12 +++++++++++
3 files changed, 33 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/7f451eeb/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 8fd414f..31e1395 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -20,10 +20,11 @@ from urllib import quote
from pylons import tmpl_context as c, app_globals as g
from pylons import request
-from tg import expose, redirect, flash, validate
+from tg import expose, redirect, flash, validate, config
from tg.decorators import with_trailing_slash, without_trailing_slash
from webob import exc
from bson import ObjectId
+from paste.deploy.converters import asbool
from ming.utils import LazyProperty
@@ -262,20 +263,34 @@ class RepoAdminController(DefaultAdminController):
@without_trailing_slash
@expose('jinja:allura:templates/repo/checkout_url.html')
def checkout_url(self):
- return dict(app=self.app)
+ return dict(app=self.app,
+ merge_allowed=not asbool(config.get('scm.merge.{}.disabled'.format(self.app.config.tool_name))),
+ )
@without_trailing_slash
@expose()
@require_post()
@validate({'external_checkout_url': v.NonHttpUrl})
def set_checkout_url(self, **post_data):
+ flash_msgs = []
external_checkout_url = (post_data.get('external_checkout_url') or '').strip()
if 'external_checkout_url' not in c.form_errors:
if (self.app.config.options.get('external_checkout_url') or '') != external_checkout_url:
self.app.config.options.external_checkout_url = external_checkout_url
- flash("External checkout URL successfully changed")
+ flash_msgs.append("External checkout URL successfully changed.")
else:
- flash("Invalid external checkout URL: %s" % c.form_errors['external_checkout_url'], "error")
+ flash_msgs.append("Invalid external checkout URL: %s." % c.form_errors['external_checkout_url'])
+
+ merge_disabled = bool(post_data.get('merge_disabled'))
+ if merge_disabled != self.app.config.options.get('merge_disabled', False):
+ self.app.config.options.merge_disabled = merge_disabled
+ flash_msgs.append('One-click merge {}.'.format('disabled' if merge_disabled else 'enabled'))
+
+ if flash_msgs:
+ message = ' '.join(flash_msgs)
+ flash(message,
+ 'error' if 'Invalid' in message else 'ok')
+
redirect(c.project.url() + 'admin/tools')
http://git-wip-us.apache.org/repos/asf/allura/blob/7f451eeb/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 7933a27..96c9358 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -831,6 +831,8 @@ class MergeRequest(VersionedArtifact, ActivityObject):
return False
if not h.has_access(c.app, 'write'):
return False
+ if self.app.config.options.get('merge_disabled'):
+ return False
return True
def can_merge(self):
http://git-wip-us.apache.org/repos/asf/allura/blob/7f451eeb/Allura/allura/templates/repo/checkout_url.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/checkout_url.html b/Allura/allura/templates/repo/checkout_url.html
index 8eaafd9..450d912 100644
--- a/Allura/allura/templates/repo/checkout_url.html
+++ b/Allura/allura/templates/repo/checkout_url.html
@@ -26,6 +26,18 @@
Override the checkout URL with an external one. This is useful if this repository is a mirror
of another, canonical repository.
</div>
+ {% if merge_allowed %}
+ <div class="grid-13"> </div>
+ <div class="grid-9">
+ <label>
+ <input type="checkbox" name="merge_disabled" {% if app.config.options.get('merge_disabled') %}checked="checked"{% endif %}/>
+ Disable one-click merge via web.
+ </label>
+ </div>
+ <div class="grid-13">
+ You may want to disable one-click merge, if this repository is a mirror and not the primary repository.
+ </div>
+ {% endif %}
<div class="grid-13"> </div>
<hr>
<div class="grid-13"> </div>