allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [2/3] allura git commit: [#8164] add subscribe icon in Merge Request action bar
Date Thu, 28 Sep 2017 14:57:13 GMT
[#8164] add subscribe icon in Merge Request action bar


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

Branch: refs/heads/master
Commit: 6785ab93f7000770b4478b4338db1c6af8b2a6e6
Parents: 48269b6
Author: Dave Brondsema <dave@brondsema.net>
Authored: Tue Sep 26 12:54:02 2017 -0400
Committer: Kenton Taylor <ktaylor@slashdotmedia.com>
Committed: Thu Sep 28 10:44:49 2017 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         | 29 +++++++++++++++++++-
 Allura/allura/templates/repo/merge_request.html |  3 ++
 2 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6785ab93/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 7b4c703..9518f89 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -359,6 +359,7 @@ class MergeRequestController(object):
         page=None, limit=None, page_size=None, count=None,
         style='linear')
     mr_dispose_form = SCMMergeRequestDisposeWidget()
+    subscribe_form = SubscribeForm(thing='merge request')
 
     def __init__(self, num):
         self.req = M.MergeRequest.query.get(
@@ -373,9 +374,18 @@ class MergeRequestController(object):
         c.thread = self.thread_widget
         c.log_widget = self.log_widget
         c.mr_dispose_form = self.mr_dispose_form
+        c.subscribe_form = self.subscribe_form
+
         limit, page = h.paging_sanitizer(limit, page)
         with self.req.push_downstream_context():
             downstream_app = c.app
+
+        tool_subscribed = M.Mailbox.subscribed()
+        if tool_subscribed:
+            subscribed = False
+        else:
+            subscribed = M.Mailbox.subscribed(artifact=self.req)
+
         result = dict(
             downstream_app=downstream_app,
             req=self.req,
@@ -384,7 +394,9 @@ class MergeRequestController(object):
             merge_status=self.req.merge_task_status(),
             page=page,
             limit=limit,
-            count=self.req.discussion_thread.post_count)
+            count=self.req.discussion_thread.post_count,
+            subscribed=subscribed,
+        )
         try:
             result['commits'] = self.req.commits
         except Exception:
@@ -495,6 +507,21 @@ class MergeRequestController(object):
         """Return result from the cache. Used by js, after task was completed."""
         return {'can_merge': self.req.can_merge()}
 
+    @expose('json:')
+    @require_post()
+    @validate(subscribe_form)
+    def subscribe(self, subscribe=None, unsubscribe=None, **kw):
+        if subscribe:
+            self.req.subscribe()
+        elif unsubscribe:
+            self.req.unsubscribe()
+        return {
+            'status': 'ok',
+            'subscribed': M.Mailbox.subscribed(artifact=self.req),
+            'subscribed_to_tool': M.Mailbox.subscribed(),
+            'subscribed_to_entire_name': 'code repository',
+        }
+
 
 class RefsController(object):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/6785ab93/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 c5517c1..fd3acdf 100644
--- a/Allura/allura/templates/repo/merge_request.html
+++ b/Allura/allura/templates/repo/merge_request.html
@@ -27,6 +27,9 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
 {% endblock %}
 
 {% block actions %}
+  {% if c.user and c.user != c.user.anonymous() %}
+    {{ c.subscribe_form.display(value=subscribed, action='subscribe', style='icon') }}
+  {% endif %}
   {% if h.has_access(req, 'write')() %}
     {{ g.icons['edit'].render(href='edit', show_title=True) }}
   {% endif %}


Mime
View raw message