Permalink
Browse files

move the UserResource to the accounts app

  • Loading branch information...
1 parent 443f279 commit 130a3d719454ff5589d495db2afa3460de90feed @daonb committed Aug 4, 2012
Showing with 26 additions and 13 deletions.
  1. +22 −0 src/knesset/accounts/api.py
  2. +1 −13 src/knesset/agendas/api.py
  3. +3 −0 src/knesset/api/resources/__init__.py
@@ -0,0 +1,22 @@
+'''
+API for the accounts app
+'''
+from django.contrib.auth.models import User
+from tastypie.constants import ALL
+import tastypie.fields as fields
+from avatar.templatetags.avatar_tags import avatar_url
+
+from knesset.api.resources.base import BaseResource
+
+class UserResource(BaseResource):
+ class Meta(BaseResource.Meta):
+ queryset = User.objects.all()
+ include_absolute_url = True
+ include_resource_uri = False
+ allowed_methods = ['get']
+ fields = ['username']
+
+ avatar = fields.CharField()
+
+ def dehydrate_avatar(self, bundle):
+ return avatar_url(bundle.obj, 48)
View
@@ -9,19 +9,7 @@
from knesset.api.resources.base import BaseResource
from knesset.mks.models import Member, Party
from knesset.agendas.models import Agenda, AgendaVote
-
-class UserResource(BaseResource):
- class Meta(BaseResource.Meta):
- queryset = User.objects.all()
- include_absolute_url = True
- include_resource_uri = False
- allowed_methods = ['get']
- fields = ['username']
-
- avatar = fields.CharField()
-
- def dehydrate_avatar(self, bundle):
- return avatar_url(bundle.obj, 48)
+from knesset.accounts.api import UserResource
class AgendaVoteResource(BaseResource):
class Meta(BaseResource.Meta):
@@ -3,12 +3,14 @@
reource in an `api.py` file under the app and than import and resiter it here
'''
from tastypie.api import Api
+
from mks.api import MemberResource, PartyResource, MemberBillsResource, MemberAgendasResource
from video.api import VideoResource
from links.api import LinkResource
from laws.api import BillResource, LawResource, VoteResource
from agendas.api import AgendaResource, AgendaTodoResource
from committees.api import CommitteeResource
+from accounts.api import UserResource
v2_api = Api(api_name='v2')
@@ -24,3 +26,4 @@
v2_api.register(AgendaResource())
v2_api.register(AgendaTodoResource())
v2_api.register(CommitteeResource())
+v2_api.register(UserResource())

0 comments on commit 130a3d7

Please sign in to comment.