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 2018/12/21 17:15:36 UTC

[07/11] allura git commit: [#5461] add subscribe option to new merge requests

[#5461] add subscribe option to new merge requests


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

Branch: refs/heads/db/5461
Commit: 517072163092a485cf351ee758fe4a24b630f936
Parents: 67fde47
Author: Dave Brondsema <da...@brondsema.net>
Authored: Wed Dec 19 18:10:43 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Dec 20 11:59:01 2018 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py |  7 ++++---
 Allura/allura/lib/widgets/repo.py       | 10 ++++++++++
 Allura/allura/model/repository.py       |  4 ++++
 3 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/51707216/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index ce7faa7..db5f9a4 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -45,7 +45,7 @@ from allura.lib.diff import HtmlSideBySideDiff
 from allura.lib.security import require_access, require_authenticated, has_access
 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
+from allura.lib.widgets.repo import SCMMergeRequestWidget, SCMMergeRequestWidgetNew
 from allura.lib.widgets.repo import SCMMergeRequestDisposeWidget, SCMCommitBrowserWidget
 from allura.lib.widgets.subscriptions import SubscribeForm
 from allura.controllers import AppDiscussionController
@@ -162,7 +162,7 @@ class RepoRootController(BaseController, FeedController):
             target_branches = [
                 b.name
                 for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
-        return SCMMergeRequestWidget(
+        return SCMMergeRequestWidgetNew(
             source_branches=source_branches,
             target_branches=target_branches)
 
@@ -197,7 +197,8 @@ class RepoRootController(BaseController, FeedController):
                 source_branch=kw['source_branch'],
                 summary=kw['summary'],
                 description=kw['description'])
-            mr.subscribe(user=c.user)
+            if kw.get('subscribe'):
+                mr.subscribe(user=c.user)
             M.Notification.post(
                 mr, 'merge_request',
                 subject=mr.email_subject,

http://git-wip-us.apache.org/repos/asf/allura/blob/51707216/Allura/allura/lib/widgets/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/repo.py b/Allura/allura/lib/widgets/repo.py
index d00640d..3a9e7d9 100644
--- a/Allura/allura/lib/widgets/repo.py
+++ b/Allura/allura/lib/widgets/repo.py
@@ -82,6 +82,16 @@ class SCMMergeRequestWidget(ff.ForgeForm):
         return result
 
 
+class SCMMergeRequestWidgetNew(SCMMergeRequestWidget):
+
+    @property
+    def buttons(self):
+        # add to after the default submit button
+        return ew_core.NameList([
+            ew.Checkbox(name='subscribe', label='Subscribe to this merge request', value=True),
+        ])
+
+
 class SCMMergeRequestDisposeWidget(ff.ForgeForm):
 
     class fields(ew_core.NameList):

http://git-wip-us.apache.org/repos/asf/allura/blob/51707216/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index cff76e3..f68580e 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -818,6 +818,10 @@ class MergeRequest(VersionedArtifact, ActivityObject):
         return 'merge request #%s' % self.request_number
 
     @property
+    def type_name(self):
+        return 'merge request'
+
+    @property
     def activity_extras(self):
         d = ActivityObject.activity_extras.fget(self)
         d.update(summary=self.summary)