summaryrefslogtreecommitdiff
path: root/coip
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-11-08 10:19:25 +0100
committerLeif Johansson <leifj@sunet.se>2011-11-08 10:19:25 +0100
commit66556015d222cbe28e0cb6b0f7aa703c5ad8e1b5 (patch)
treec09c2752e609596e592f6acd25b37b694abebeaa /coip
parent4e22d7a32e3e68f27f2e26b14e22d88c4e68cd25 (diff)
a simple activity stream for names
Diffstat (limited to 'coip')
-rw-r--r--coip/apps/activitystreams/__init__.py0
-rw-r--r--coip/apps/activitystreams/managers.py17
-rw-r--r--coip/apps/activitystreams/urls.py10
-rw-r--r--coip/apps/activitystreams/views.py14
-rw-r--r--coip/settings.py1
-rw-r--r--coip/urls.py8
6 files changed, 47 insertions, 3 deletions
diff --git a/coip/apps/activitystreams/__init__.py b/coip/apps/activitystreams/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/coip/apps/activitystreams/__init__.py
diff --git a/coip/apps/activitystreams/managers.py b/coip/apps/activitystreams/managers.py
new file mode 100644
index 0000000..aaa73f9
--- /dev/null
+++ b/coip/apps/activitystreams/managers.py
@@ -0,0 +1,17 @@
+'''
+Created on Nov 8, 2011
+
+@author: leifj
+'''
+from actstream.models import ActionManager
+from actstream.views import stream
+from datetime import datetime
+
+
+class NameActionManager(ActionManager):
+
+ @stream
+ def name_activities(self, name, time=None):
+ if time is None:
+ time = datetime.now()
+ return name.actor_actions.filter(timestamp__lte = time) \ No newline at end of file
diff --git a/coip/apps/activitystreams/urls.py b/coip/apps/activitystreams/urls.py
new file mode 100644
index 0000000..e5d0d94
--- /dev/null
+++ b/coip/apps/activitystreams/urls.py
@@ -0,0 +1,10 @@
+'''
+Created on Nov 7, 2011
+
+@author: leifj
+'''
+from django.conf.urls.defaults import patterns, url
+
+urlpatterns = patterns('',
+ url(r'^@any/(?P<id>[0-9]+)', view='coip.apps.activitystreams.urls')
+) \ No newline at end of file
diff --git a/coip/apps/activitystreams/views.py b/coip/apps/activitystreams/views.py
new file mode 100644
index 0000000..a99bec3
--- /dev/null
+++ b/coip/apps/activitystreams/views.py
@@ -0,0 +1,14 @@
+'''
+Created on Nov 8, 2011
+
+@author: leifj
+'''
+from django.shortcuts import get_object_or_404
+from coip.apps.name.models import Name
+from coip.multiresponse import json_response
+
+@oauth2_required(scope='memberships')
+def name(request,id):
+ name = get_object_or_404(Name,pk=id)
+ # check ownership
+ return json_response(name.actor_actions.name_activities()) \ No newline at end of file
diff --git a/coip/settings.py b/coip/settings.py
index d3b86c9..9357607 100644
--- a/coip/settings.py
+++ b/coip/settings.py
@@ -113,6 +113,7 @@ INSTALLED_APPS = (
'coip.apps.invitation',
'coip.apps.userprofile',
'coip.apps.link',
+ 'coip.apps.activitystreams'
)
OAUTH_REALM_KEY_NAME = 'http://coip-test.sunet.se'
diff --git a/coip/urls.py b/coip/urls.py
index 49df4d4..e41a47a 100644
--- a/coip/urls.py
+++ b/coip/urls.py
@@ -71,9 +71,11 @@ urlpatterns = patterns('',
(r'^rtree.json$', 'coip.apps.name.views.rtree'),
(r'^rtree/(?P<id>[0-9]+).json$', 'coip.apps.name.views.rtree'),
# APIs
+ (r'^api/activitystreams', include('coip.apps.activitystreams.urls')),
+ (r'^api/opensocial/1.0/rpc', 'coip.apps.opensocial.common.system'),
+ #(r'^opensocial/2.0/activitystreams', include(opensocial_v2_as.urls)),
+ (r'^api/opensocial/', include(opensocial_v1.urls)),
+ (r'^api/hello/?', 'coip.apps.name.views.hello'),
(r'^api/', include(v1_api.urls)),
- (r'^opensocial/1.0/rpc', 'coip.apps.opensocial.common.system'),
- (r'^opensocial/', include(opensocial_v1.urls)),
- (r'^hello/?', 'coip.apps.name.views.hello'),
(r'^oauth2/', include('django_oauth2_lite.urls'))
)