You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/12/12 00:00:45 UTC

[1/2] git commit: [#6831] Allow standard browser session to auth REST API

Updated Branches:
  refs/heads/cj/6831 [created] 3486f3455


[#6831] Allow standard browser session to auth REST API

Signed-off-by: Cory Johns <ad...@users.sf.net>


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

Branch: refs/heads/cj/6831
Commit: 391787399330d6b75d06d084038df63f79169bc2
Parents: fcf2e46
Author: Cory Johns <ad...@users.sf.net>
Authored: Tue Dec 10 20:30:37 2013 +0000
Committer: Cory Johns <ad...@users.sf.net>
Committed: Tue Dec 10 20:31:00 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/rest.py | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/39178739/Allura/allura/controllers/rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index 5c223f5..3566caa 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -96,12 +96,9 @@ class RestController(object):
 
     @expose()
     def _lookup(self, name, *remainder):
-        api_token = self._authenticate_request()
-        c.api_token = api_token
-        if api_token:
-            c.user = api_token.user
-        else:
-            c.user = M.User.anonymous()
+        c.api_token = self._authenticate_request()
+        if c.api_token:
+            c.user = c.api_token.user
         neighborhood = M.Neighborhood.query.get(url_prefix = '/' + name + '/')
         if not neighborhood: raise exc.HTTPNotFound, name
         return NeighborhoodRestController(neighborhood), remainder


[2/2] git commit: [#6831] Added API controller for ForgeActivity

Posted by jo...@apache.org.
[#6831] Added API controller for ForgeActivity

Signed-off-by: Cory Johns <ad...@users.sf.net>


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

Branch: refs/heads/cj/6831
Commit: 3486f34559fe4b095ab5cf961566fb9c57e0cc00
Parents: 3917873
Author: Cory Johns <ad...@users.sf.net>
Authored: Tue Dec 10 20:42:50 2013 +0000
Committer: Cory Johns <ad...@users.sf.net>
Committed: Wed Dec 11 22:31:29 2013 +0000

----------------------------------------------------------------------
 ForgeActivity/forgeactivity/main.py | 43 ++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3486f345/ForgeActivity/forgeactivity/main.py
----------------------------------------------------------------------
diff --git a/ForgeActivity/forgeactivity/main.py b/ForgeActivity/forgeactivity/main.py
index 3d1e62f..daeb1ce 100644
--- a/ForgeActivity/forgeactivity/main.py
+++ b/ForgeActivity/forgeactivity/main.py
@@ -47,6 +47,7 @@ class ForgeActivityApp(Application):
     def __init__(self, project, config):
         Application.__init__(self, project, config)
         self.root = ForgeActivityController(self)
+        self.api_root = ForgeActivityRestController(self)
 
     def main_menu(self): # pragma no cover
         return []
@@ -132,3 +133,45 @@ class ForgeActivityController(BaseController):
             success=True,
             message=W.follow_toggle.success_message(follow),
             following=follow)
+
+
+class ForgeActivityRestController(BaseController):
+    def __init__(self, app, *args, **kw):
+        super(ForgeActivityRestController, self).__init__(*args, **kw)
+        self.app = app
+
+    @expose('json:')
+    def index(self, **kw):
+        activity_enabled = config.get('activitystream.enabled', False)
+        activity_enabled = request.cookies.get('activitystream.enabled', activity_enabled)
+        activity_enabled = asbool(activity_enabled)
+        if not activity_enabled:
+            raise exc.HTTPNotFound()
+
+        c.follow_toggle = W.follow_toggle
+        if c.project.is_user_project:
+            followee = c.project.user_project_of
+            actor_only = followee != c.user
+        else:
+            followee = c.project
+            actor_only = False
+
+        following = g.director.is_connected(c.user, followee)
+        timeline = g.director.get_timeline(followee, page=kw.get('page', 0),
+                limit=kw.get('limit', 100), actor_only=actor_only,
+                filter_func=perm_check(c.user))
+        return {
+                'following': following,
+                'followee': {
+                    'activity_name': followee.shortname,
+                    'activity_url': followee.url(),
+                    'activity_extras': {},
+                },
+                'timeline': [{
+                        'published': '%s UTC' % a.published,
+                        'actor': a.actor._deinstrument(),
+                        'verb': a.verb,
+                        'obj': a.obj._deinstrument(),
+                        'target': a.target._deinstrument(),
+                    } for a in timeline],
+            }