allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [05/10] allura git commit: [#8253] JSON Endpoint for reactions
Date Thu, 08 Nov 2018 21:53:46 GMT
[#8253] JSON Endpoint for reactions


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

Branch: refs/heads/master
Commit: 73490b075af289620f7fd7b94833743f6d1456ec
Parents: 62df9f2
Author: Shalitha <shalithasuranga@gmail.com>
Authored: Tue Oct 30 22:04:01 2018 +0530
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Nov 8 21:53:25 2018 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/73490b07/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 6bdc289..f2ea923 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -370,6 +370,29 @@ class PostController(BaseController):
     def get_markdown(self):
         return self.post.text
 
+    @expose('json:')
+    @without_trailing_slash
+    @require_post()
+    def post_reaction(self, r, **kw):
+        if c.user.is_anonymous():
+            return {
+                'error' : 'no_permission'
+            }
+        status = 'ok'
+        if r in self.post.reaction_list:
+            self.post.post_reaction(r, c.user)
+        else:
+            status = 'error' 
+        return {
+            'status' : status,
+            'react_thumbs_up': self.post.react_thumbs_up,
+            'react_thumbs_down': self.post.react_thumbs_down,
+            'react_laugh': self.post.react_laugh,
+            'react_hooray': self.post.react_hooray,
+            'react_confused': self.post.react_confused,
+            'react_heart': self.post.react_heart
+        }
+
     def error_handler(self, *args, **kwargs):
         redirect(request.referer)
 


Mime
View raw message