You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2014/02/21 18:37:08 UTC

[1/4] git commit: [#6164] ticket:537 add new template for edit, add new link and metod, fix css

Repository: incubator-allura
Updated Branches:
  refs/heads/master 119afc3a6 -> a75304309


[#6164] ticket:537 add new template for edit, add new link and metod, fix css


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/108e2ef3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/108e2ef3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/108e2ef3

Branch: refs/heads/master
Commit: 108e2ef3eab384d22a15f7bcc1d9cef187a89dfd
Parents: 119afc3
Author: tramzzz <st...@gmail.com>
Authored: Tue Feb 11 18:32:39 2014 +0200
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Feb 21 17:19:43 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         | 43 ++++++++++++++++++++
 Allura/allura/nf/allura/css/site_style.css      |  3 ++
 .../templates/repo/merge_request_edit.html      | 33 +++++++++++++++
 3 files changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/108e2ef3/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 1fb8323..e359885 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -367,6 +367,49 @@ class MergeRequestController(object):
             limit=limit,
             count=self.req.discussion_thread.post_count)
 
+    @property
+    def mr_widget_edit(self):
+        source_branches = [
+            b.name
+            for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
+        target_branches = [
+            b.name
+            for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
+        return SCMMergeRequestWidget(
+            source_branches=source_branches,
+            target_branches=target_branches)
+
+    @expose('jinja:allura:templates/repo/merge_request_edit.html')
+    def edit(self, **kw):
+        c.form = self.mr_widget_edit
+        if self.req['source_branch'] in c.form.source_branches:
+            source_branch = self.req['source_branch']
+        else:
+            source_branch = c.app.default_branch_name
+        if self.req['target_branch'] in c.form.target_branches:
+            target_branch = self.req['source_branch']
+        else:
+            target_branch = c.app.default_branch_name
+        return {
+            'source_branch': source_branch,
+            'target_branch': target_branch,
+            'description': self.req['description'],
+            'summary': self.req['summary']
+        }
+
+    @expose()
+    @require_post()
+    def do_request_merge_edit(self, **kw):
+        kw = self.mr_widget_edit.to_python(kw)
+        mr = M.MergeRequest.query.get(request_number=self.req['request_number'])
+        mr.target_branch = kw['target_branch']
+        mr.source_branch = kw['source_branch']
+        mr.description = kw['description']
+        M.Notification.post(
+            mr, 'merge_request',
+            subject='Merge request: ' + mr.summary)
+        redirect(mr.url())
+
     @expose()
     @require_post()
     @validate(mr_dispose_form)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/108e2ef3/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 94f5d09..cd28a15 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -3294,3 +3294,6 @@ ul.dropdown ul li a:hover {
     text-align: right;
     padding: 5px 10px 5px 0;
 }
+.markdown_preview.btn.edit{
+    margin-left: 10px;
+}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/108e2ef3/Allura/allura/templates/repo/merge_request_edit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/merge_request_edit.html b/Allura/allura/templates/repo/merge_request_edit.html
new file mode 100644
index 0000000..88bdfc0
--- /dev/null
+++ b/Allura/allura/templates/repo/merge_request_edit.html
@@ -0,0 +1,33 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+{% extends 'allura:templates/repo/repo_master.html' %}
+
+{% block title %}
+  {% if c.app.repo %}
+    Repository: {{c.app.repo.name}}
+  {% else %}
+    Repository
+  {% endif %}
+{% endblock %}
+
+{% block header %}Request merge of {{c.app.config.options.mount_label}} {% endblock %}
+
+{% block content %}
+  {{ c.form.display(action='do_request_merge_edit', value=dict(source_branch=source_branch, target_branch=target_branch, description=description, summary=summary))}}
+{% endblock %}


[2/4] git commit: [#6164] ticket:537 add test, fix controler for anonimus user, fix template and css

Posted by tv...@apache.org.
[#6164] ticket:537 add test, fix controler for anonimus user, fix template and css


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/ee36ba2a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ee36ba2a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ee36ba2a

Branch: refs/heads/master
Commit: ee36ba2ac9d4b815675fb96c1aaf2efe3192e19f
Parents: 108e2ef
Author: tramzzz <st...@gmail.com>
Authored: Tue Feb 18 14:42:28 2014 +0200
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Feb 21 17:35:57 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         |  5 +++
 Allura/allura/nf/allura/css/site_style.css      |  6 ++--
 .../tests/functional/test_controllers.py        | 33 ++++++++++++++++++++
 3 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee36ba2a/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index e359885..547af55 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -381,6 +381,8 @@ class MergeRequestController(object):
 
     @expose('jinja:allura:templates/repo/merge_request_edit.html')
     def edit(self, **kw):
+        security.require(
+            security.has_access(self.req, 'write'), 'Write access required')
         c.form = self.mr_widget_edit
         if self.req['source_branch'] in c.form.source_branches:
             source_branch = self.req['source_branch']
@@ -400,8 +402,11 @@ class MergeRequestController(object):
     @expose()
     @require_post()
     def do_request_merge_edit(self, **kw):
+        security.require(
+            security.has_access(self.req, 'write'), 'Write access required')
         kw = self.mr_widget_edit.to_python(kw)
         mr = M.MergeRequest.query.get(request_number=self.req['request_number'])
+        mr.summary = kw['summary']
         mr.target_branch = kw['target_branch']
         mr.source_branch = kw['source_branch']
         mr.description = kw['description']

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee36ba2a/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index cd28a15..77009c4 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -3294,6 +3294,8 @@ ul.dropdown ul li a:hover {
     text-align: right;
     padding: 5px 10px 5px 0;
 }
-.markdown_preview.btn.edit{
-    margin-left: 10px;
+.markdown_preview.btn.edit {
+    margin-left: 240px;
+    margin-top: -35px;
+    padding: 4px 13px 3px;
 }

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee36ba2a/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 3badb92..798c77a 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -599,6 +599,39 @@ class TestFork(_TestCase):
                               'description': 'description'}).follow()
         assert '[5c4724]' in r
 
+    def test_merge_request_edit(self):
+        r = self.app.post('/p/test2/code/do_request_merge',
+            params={
+                'source_branch': 'zz',
+                'target_branch': 'master',
+                'summary': 'summary',
+                'description': 'description'}).follow()
+        assert 'href="edit">Edit</a>' in r
+        r = self.app.get('/p/test/src-git/merge-requests/1/edit')
+        assert 'value="summary"' in r
+        assert 'name="description">description</textarea>' in r
+        assert '<option selected value="zz">zz</option>' in r
+
+        r = self.app.post('/p/test/src-git/merge-requests/1/do_request_merge_edit',
+            params={
+                'source_branch': 'zz',
+                'target_branch': 'master',
+                'summary': 'changed summary',
+                'description': 'changed description'},
+                extra_environ=dict(username='*anonymous'), status=302).follow()
+        assert 'Login' in r
+
+        r = self.app.post('/p/test/src-git/merge-requests/1/do_request_merge_edit',
+            params={
+                'source_branch': 'zz',
+                'target_branch': 'master',
+                'summary': 'changed summary',
+                'description': 'changed description'}).follow()
+        assert '<p>changed description</p' in r
+
+        r = self.app.post('/p/test/src-git/merge-requests')
+        assert '<a href="1/">changed summary</a>' in r
+
 
 class TestDiff(TestController):
 


[4/4] git commit: [#6164] ticket:537 fixed a branch error in merge request

Posted by tv...@apache.org.
[#6164] ticket:537 fixed a branch error in  merge request


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4601179b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4601179b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4601179b

Branch: refs/heads/master
Commit: 4601179b57daaee70728e94dcc5f0a88cba0712d
Parents: ee36ba2
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Thu Feb 20 15:51:31 2014 +0400
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Feb 21 17:35:57 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py                | 11 +++++++----
 Allura/allura/nf/allura/css/site_style.css             |  5 -----
 Allura/allura/templates/repo/merge_request.html        |  3 +++
 Allura/allura/templates/repo/merge_request_edit.html   |  2 +-
 ForgeGit/forgegit/tests/functional/test_controllers.py |  9 ++++++---
 5 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4601179b/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 547af55..7fb1a7e 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -369,12 +369,13 @@ class MergeRequestController(object):
 
     @property
     def mr_widget_edit(self):
-        source_branches = [
-            b.name
-            for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
         target_branches = [
             b.name
             for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
+        with self.req.push_downstream_context():
+            source_branches = [
+                b.name
+                for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
         return SCMMergeRequestWidget(
             source_branches=source_branches,
             target_branches=target_branches)
@@ -389,7 +390,7 @@ class MergeRequestController(object):
         else:
             source_branch = c.app.default_branch_name
         if self.req['target_branch'] in c.form.target_branches:
-            target_branch = self.req['source_branch']
+            target_branch = self.req['target_branch']
         else:
             target_branch = c.app.default_branch_name
         return {
@@ -410,6 +411,8 @@ class MergeRequestController(object):
         mr.target_branch = kw['target_branch']
         mr.source_branch = kw['source_branch']
         mr.description = kw['description']
+        with self.req.push_downstream_context():
+            mr.downstream['commit_id'] = c.app.repo.commit(kw['source_branch'])._id
         M.Notification.post(
             mr, 'merge_request',
             subject='Merge request: ' + mr.summary)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4601179b/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 77009c4..94f5d09 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -3294,8 +3294,3 @@ ul.dropdown ul li a:hover {
     text-align: right;
     padding: 5px 10px 5px 0;
 }
-.markdown_preview.btn.edit {
-    margin-left: 240px;
-    margin-top: -35px;
-    padding: 4px 13px 3px;
-}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4601179b/Allura/allura/templates/repo/merge_request.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/merge_request.html b/Allura/allura/templates/repo/merge_request.html
index 7eabc41..00aa0b0 100644
--- a/Allura/allura/templates/repo/merge_request.html
+++ b/Allura/allura/templates/repo/merge_request.html
@@ -29,6 +29,9 @@
 {% block header %}{{c.app.config.options.mount_label}}
 Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
 {% endblock %}
+{% block actions %}
+      <a href="edit" title="Edit"><b data-icon="{{g.icons['pencil'].char}}" class="ico {{g.icons['pencil'].css}}" title="Edit"></b></a>
+{% endblock %}
 
 {% block content %}
   {% if req.downstream_repo %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4601179b/Allura/allura/templates/repo/merge_request_edit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/merge_request_edit.html b/Allura/allura/templates/repo/merge_request_edit.html
index 88bdfc0..86d0420 100644
--- a/Allura/allura/templates/repo/merge_request_edit.html
+++ b/Allura/allura/templates/repo/merge_request_edit.html
@@ -26,7 +26,7 @@
   {% endif %}
 {% endblock %}
 
-{% block header %}Request merge of {{c.app.config.options.mount_label}} {% endblock %}
+{% block header %}Update merge request{% endblock %}
 
 {% block content %}
   {{ c.form.display(action='do_request_merge_edit', value=dict(source_branch=source_branch, target_branch=target_branch, description=description, summary=summary))}}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4601179b/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 798c77a..999af5b 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -606,7 +606,7 @@ class TestFork(_TestCase):
                 'target_branch': 'master',
                 'summary': 'summary',
                 'description': 'description'}).follow()
-        assert 'href="edit">Edit</a>' in r
+        assert '<a href="edit" title="Edit"><b data-icon="p" class="ico ico-pencil" title="Edit"></b></a>' in r
         r = self.app.get('/p/test/src-git/merge-requests/1/edit')
         assert 'value="summary"' in r
         assert 'name="description">description</textarea>' in r
@@ -623,13 +623,16 @@ class TestFork(_TestCase):
 
         r = self.app.post('/p/test/src-git/merge-requests/1/do_request_merge_edit',
             params={
-                'source_branch': 'zz',
+                'source_branch': 'master',
                 'target_branch': 'master',
                 'summary': 'changed summary',
                 'description': 'changed description'}).follow()
+
+        assert '[5c4724]' not in r
         assert '<p>changed description</p' in r
+        assert 'Merge Request #1: changed summary (open)' in r
 
-        r = self.app.post('/p/test/src-git/merge-requests')
+        r = self.app.get('/p/test/src-git/merge-requests')
         assert '<a href="1/">changed summary</a>' in r
 
 


[3/4] git commit: [#6164] Bug fixes/clean up on merge request edits

Posted by tv...@apache.org.
[#6164] Bug fixes/clean up on merge request edits

- Fix bug fetching MR w/o specifying app_config_id
- Only show Edit icon if user has write access
- Clean up security access checks and imports

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/a7530430
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a7530430
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a7530430

Branch: refs/heads/master
Commit: a7530430964836efd5dbe579d1dc1abbe4114624
Parents: 4601179
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Fri Feb 21 17:19:30 2014 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Feb 21 17:35:57 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         | 48 +++++++++-----------
 Allura/allura/templates/repo/merge_request.html |  5 +-
 2 files changed, 26 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a7530430/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 7fb1a7e..eecd563 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -22,6 +22,7 @@ from urllib import quote, unquote
 from collections import defaultdict
 from itertools import islice
 
+from paste.deploy.converters import asbool
 from pylons import tmpl_context as c, app_globals as g
 from pylons import request, response
 from webob import exc
@@ -35,22 +36,21 @@ from ming.base import Object
 from ming.orm import ThreadLocalORMSession, session
 
 import allura.tasks
-from allura.lib import security
+from allura import model as M
 from allura.lib import utils
 from allura.lib import helpers as h
 from allura.lib import widgets as w
 from allura.lib.decorators import require_post
-from allura.controllers import AppDiscussionController
+from allura.lib.diff import HtmlSideBySideDiff
+from allura.lib.security import require_access, require_authenticated
+from allura.lib.widgets import form_fields as ffw
 from allura.lib.widgets.repo import SCMLogWidget, SCMRevisionWidget, SCMTreeWidget
 from allura.lib.widgets.repo import SCMMergeRequestWidget, SCMMergeRequestFilterWidget
 from allura.lib.widgets.repo import SCMMergeRequestDisposeWidget, SCMCommitBrowserWidget
 from allura.lib.widgets.subscriptions import SubscribeForm
-from allura import model as M
-from allura.lib.widgets import form_fields as ffw
+from allura.controllers import AppDiscussionController
 from allura.controllers.base import DispatchIndex
 from allura.controllers.feed import FeedController, FeedArgs
-from allura.lib.diff import HtmlSideBySideDiff
-from paste.deploy.converters import asbool
 from .base import BaseController
 
 log = logging.getLogger(__name__)
@@ -75,7 +75,7 @@ class RepoRootController(BaseController, FeedController):
         return FeedArgs(query, title, app.url, description=description)
 
     def _check_security(self):
-        security.require(security.has_access(c.app, 'read'))
+        require_access(c.app, 'read')
 
     @with_trailing_slash
     @expose()
@@ -112,7 +112,7 @@ class RepoRootController(BaseController, FeedController):
     @expose('jinja:allura:templates/repo/fork.html')
     def fork(self, project_id=None, mount_point=None, mount_label=None, **kw):
         # this shows the form and handles the submission
-        security.require_authenticated()
+        require_authenticated()
         if not c.app.forkable:
             raise exc.HTTPNotFound
         from_repo = c.app.repo
@@ -132,7 +132,7 @@ class RepoRootController(BaseController, FeedController):
             with h.push_config(c, project=to_project):
                 if not to_project.database_configured:
                     to_project.configure_project(is_user_project=True)
-                security.require(security.has_access(to_project, 'admin'))
+                require_access(to_project, 'admin')
                 try:
                     to_project.install_app(
                         ep_name=from_repo.tool_name,
@@ -163,7 +163,7 @@ class RepoRootController(BaseController, FeedController):
     @without_trailing_slash
     @expose('jinja:allura:templates/repo/request_merge.html')
     def request_merge(self, branch=None, **kw):
-        security.require(security.has_access(c.app.repo, 'admin'))
+        require_access(c.app.repo, 'admin')
         c.form = self.mr_widget
         if branch in c.form.source_branches:
             source_branch = branch
@@ -382,8 +382,7 @@ class MergeRequestController(object):
 
     @expose('jinja:allura:templates/repo/merge_request_edit.html')
     def edit(self, **kw):
-        security.require(
-            security.has_access(self.req, 'write'), 'Write access required')
+        require_access(self.req, 'write')
         c.form = self.mr_widget_edit
         if self.req['source_branch'] in c.form.source_branches:
             source_branch = self.req['source_branch']
@@ -403,27 +402,24 @@ class MergeRequestController(object):
     @expose()
     @require_post()
     def do_request_merge_edit(self, **kw):
-        security.require(
-            security.has_access(self.req, 'write'), 'Write access required')
+        require_access(self.req, 'write')
         kw = self.mr_widget_edit.to_python(kw)
-        mr = M.MergeRequest.query.get(request_number=self.req['request_number'])
-        mr.summary = kw['summary']
-        mr.target_branch = kw['target_branch']
-        mr.source_branch = kw['source_branch']
-        mr.description = kw['description']
+        self.req.summary = kw['summary']
+        self.req.target_branch = kw['target_branch']
+        self.req.source_branch = kw['source_branch']
+        self.req.description = kw['description']
         with self.req.push_downstream_context():
-            mr.downstream['commit_id'] = c.app.repo.commit(kw['source_branch'])._id
+            self.req.downstream['commit_id'] = c.app.repo.commit(kw['source_branch'])._id
         M.Notification.post(
-            mr, 'merge_request',
-            subject='Merge request: ' + mr.summary)
-        redirect(mr.url())
+            self.req, 'merge_request',
+            subject='Merge request: ' + self.req.summary)
+        redirect(self.req.url())
 
     @expose()
     @require_post()
     @validate(mr_dispose_form)
     def save(self, status=None, **kw):
-        security.require(
-            security.has_access(self.req, 'write'), 'Write access required')
+        require_access(self.req, 'write')
         self.req.status = status
         redirect('.')
 
@@ -462,7 +458,7 @@ class BranchBrowser(BaseController):
         self._branch = branch
 
     def _check_security(self):
-        security.require(security.has_access(c.app.repo, 'read'))
+        require_access(c.app.repo, 'read')
 
     @expose('jinja:allura:templates/repo/tags.html')
     @with_trailing_slash

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a7530430/Allura/allura/templates/repo/merge_request.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/merge_request.html b/Allura/allura/templates/repo/merge_request.html
index 00aa0b0..4454066 100644
--- a/Allura/allura/templates/repo/merge_request.html
+++ b/Allura/allura/templates/repo/merge_request.html
@@ -29,8 +29,11 @@
 {% block header %}{{c.app.config.options.mount_label}}
 Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
 {% endblock %}
+
 {% block actions %}
-      <a href="edit" title="Edit"><b data-icon="{{g.icons['pencil'].char}}" class="ico {{g.icons['pencil'].css}}" title="Edit"></b></a>
+  {% if h.has_access(req, 'write')() %}
+    <a href="edit" title="Edit"><b data-icon="{{g.icons['pencil'].char}}" class="ico {{g.icons['pencil'].css}}" title="Edit"></b></a>
+  {% endif %}
 {% endblock %}
 
 {% block content %}