allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [9/9] allura git commit: [#7981] add per-thread subscription icon
Date Mon, 05 Dec 2016 16:39:42 GMT
[#7981] add per-thread subscription icon


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

Branch: refs/heads/master
Commit: 3b8240fc25e58976aafcccc946a984865c8d03cb
Parents: 91837a7
Author: Dave Brondsema <dave@brondsema.net>
Authored: Wed Nov 30 16:23:31 2016 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Mon Dec 5 11:39:21 2016 -0500

----------------------------------------------------------------------
 .../lib/widgets/resources/js/subscriptions.js   |  6 ++++--
 .../forgediscussion/controllers/forum.py        | 20 ++++++++++++++++++++
 .../templates/discussionforums/thread.html      |  1 +
 .../forgediscussion/templates/index.html        |  2 +-
 ForgeTracker/forgetracker/tracker_main.py       |  1 +
 ForgeWiki/forgewiki/wiki_main.py                |  1 +
 6 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/3b8240fc/Allura/allura/lib/widgets/resources/js/subscriptions.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/subscriptions.js b/Allura/allura/lib/widgets/resources/js/subscriptions.js
index 5e61caf..14d37a7 100644
--- a/Allura/allura/lib/widgets/resources/js/subscriptions.js
+++ b/Allura/allura/lib/widgets/resources/js/subscriptions.js
@@ -69,10 +69,12 @@ SubscriptionForm = React.createClass({
         if (resp.subscribed_to_tool) {
           text = "You can't subscribe to this ";
           text += this.props.thing;
-          text += " because you are already subscribed to the entire tool";
+          text += " because you are already subscribed to the entire ";
+          text += resp.subscribed_to_entire_name ? resp.subscribed_to_entire_name : "tool";
+          text += ".";
         } else {
           var action = resp.subscribed ? 'subscribed to' : 'unsubscribed from';
-          text = 'Successfully ' + action + ' this ' + this.props.thing;
+          text = 'Successfully ' + action + ' this ' + this.props.thing + '.';
         }
         $(link).tooltipster('content', text).tooltipster('show');
         if (this.state.tooltip_timeout) {

http://git-wip-us.apache.org/repos/asf/allura/blob/3b8240fc/ForgeDiscussion/forgediscussion/controllers/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/forum.py b/ForgeDiscussion/forgediscussion/controllers/forum.py
index 3b81842..ee00fe2 100644
--- a/ForgeDiscussion/forgediscussion/controllers/forum.py
+++ b/ForgeDiscussion/forgediscussion/controllers/forum.py
@@ -161,6 +161,7 @@ class ForumController(DiscussionController):
 
 
 class ForumThreadController(ThreadController):
+    W = WidgetConfig
 
     @expose('jinja:forgediscussion:templates/discussionforums/thread.html')
     @validate(dict(page=validators.Int(if_empty=0, if_invalid=0),
@@ -168,6 +169,7 @@ class ForumThreadController(ThreadController):
     def index(self, limit=25, page=0, count=0, **kw):
         if self.thread.discussion.deleted and not has_access(c.app, 'configure')():
             redirect(self.thread.discussion.url() + 'deleted')
+        c.thread_subscription_form = self.W.subscribe_form
         return super(ForumThreadController, self).index(limit=limit, page=page, count=count,
show_moderate=True, **kw)
 
     @h.vardec
@@ -191,6 +193,24 @@ class ForumThreadController(ThreadController):
         self.thread.flags = args.pop('flags', [])
         redirect(self.thread.url())
 
+    @expose('json:')
+    @require_post()
+    @validate(W.subscribe_form)
+    def subscribe(self, subscribe=None, unsubscribe=None, **kw):
+        if subscribe:
+            self.thread.subscribe()
+        elif unsubscribe:
+            self.thread.unsubscribe()
+
+        sub_tool = M.Mailbox.subscribed()
+        sub_forum = M.Mailbox.subscribed(artifact=self.discussion)
+        return {
+            'status': 'ok',
+            'subscribed': M.Mailbox.subscribed(artifact=self.thread),
+            'subscribed_to_tool': sub_tool or sub_forum,
+            'subscribed_to_entire_name': 'forum' if sub_forum else 'discussion tool',
+        }
+
 
 class ForumPostController(PostController):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/3b8240fc/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html b/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
index 367cd8a..d37d044 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
@@ -31,6 +31,7 @@
   {% endif %}
   {# {{ g.icons['tag'].render(title='Label This', extra_css='thread_tag') }}   these labels
aren't used anywhere ... #}
   {{ g.icons['feed'].render(href='feed.rss', title='Follow This', extra_css='thread_feed0')
}}
+  {{ c.thread_subscription_form.display(value=thread.subscribed(), action='subscribe', style='icon',
thing='thread') }}
 {% endblock %}
 
 {% block edit_box %}

http://git-wip-us.apache.org/repos/asf/allura/blob/3b8240fc/ForgeDiscussion/forgediscussion/templates/index.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/index.html b/ForgeDiscussion/forgediscussion/templates/index.html
index da2c3a9..b43fedc 100644
--- a/ForgeDiscussion/forgediscussion/templates/index.html
+++ b/ForgeDiscussion/forgediscussion/templates/index.html
@@ -21,5 +21,5 @@
 
 {% block actions %}
   {{ super() }}
-  {{c.whole_forum_subscription_form.display(value=c.subscribed, action='subscribe_to_forum',
style='icon', thing='discussion')}}
+  {{c.whole_forum_subscription_form.display(value=c.subscribed, action='subscribe_to_forum',
style='icon', thing='forum')}}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/3b8240fc/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 42dffb3..3227c4f 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1559,6 +1559,7 @@ class TicketController(BaseController, FeedController):
             'status': 'ok',
             'subscribed': M.Mailbox.subscribed(artifact=self.ticket),
             'subscribed_to_tool': M.Mailbox.subscribed(),
+            'subscribed_to_entire_name': 'ticket tracker',
         }
 
     @expose('json:')

http://git-wip-us.apache.org/repos/asf/allura/blob/3b8240fc/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 379914a..3fb7fb3 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -793,6 +793,7 @@ class PageController(BaseController, FeedController):
             'status': 'ok',
             'subscribed': M.Mailbox.subscribed(artifact=self.page),
             'subscribed_to_tool': M.Mailbox.subscribed(),
+            'subscribed_to_entire_name': 'wiki',
         }
 
 


Mime
View raw message