diff options
Diffstat (limited to 'coip/apps/opensocial')
-rw-r--r-- | coip/apps/opensocial/activitystreams/__init__.py | 0 | ||||
-rw-r--r-- | coip/apps/opensocial/activitystreams/managers.py | 17 | ||||
-rw-r--r-- | coip/apps/opensocial/activitystreams/urls.py | 10 | ||||
-rw-r--r-- | coip/apps/opensocial/activitystreams/views.py | 14 | ||||
-rw-r--r-- | coip/apps/opensocial/people.py | 8 |
5 files changed, 49 insertions, 0 deletions
diff --git a/coip/apps/opensocial/activitystreams/__init__.py b/coip/apps/opensocial/activitystreams/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/coip/apps/opensocial/activitystreams/__init__.py diff --git a/coip/apps/opensocial/activitystreams/managers.py b/coip/apps/opensocial/activitystreams/managers.py new file mode 100644 index 0000000..aaa73f9 --- /dev/null +++ b/coip/apps/opensocial/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/opensocial/activitystreams/urls.py b/coip/apps/opensocial/activitystreams/urls.py new file mode 100644 index 0000000..e5d0d94 --- /dev/null +++ b/coip/apps/opensocial/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/opensocial/activitystreams/views.py b/coip/apps/opensocial/activitystreams/views.py new file mode 100644 index 0000000..a99bec3 --- /dev/null +++ b/coip/apps/opensocial/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/apps/opensocial/people.py b/coip/apps/opensocial/people.py index bf814e2..613ef68 100644 --- a/coip/apps/opensocial/people.py +++ b/coip/apps/opensocial/people.py @@ -17,6 +17,8 @@ from django.shortcuts import get_object_or_404 import logging from pprint import pformat from coip.apps.opensocial.common import OpenSocialResource +from tastypie.authentication import OAuthAuthentication +from tastypie.authorization import DjangoAuthorization class GroupResource(OpenSocialResource): @@ -25,6 +27,8 @@ class GroupResource(OpenSocialResource): serializer = OpenSocialSerializer() resource_name = 'groups' fields = ['short','description','id'] + authentication = OAuthAuthentication() + authorization = DjangoAuthorization() def override_urls(self): return [ @@ -68,6 +72,8 @@ class MembershipResource(OpenSocialResource): class Meta: queryset = Membership.objects.all() serializer = OpenSocialSerializer() + authentication = OAuthAuthentication() + authorization = DjangoAuthorization() resource_name = 'membership' fields = ['user','name'] filtering = { @@ -86,6 +92,8 @@ class PersonResource(OpenSocialResource): class Meta: queryset = User.objects.all() + authentication = OAuthAuthentication() + authorization = DjangoAuthorization() fields = ['username'] resource_name = 'people' serializer = OpenSocialSerializer() |