Created
August 9, 2012 00:06
-
-
Save omarish/3299867 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Urls | |
# | |
from django.conf.urls.defaults import patterns, url, include | |
from django.contrib import admin | |
from tastypie.api import Api | |
from resources import UserResource, FollowResource, FollowItemResource | |
admin.autodiscover() | |
v1_api = Api("v1_api") | |
v1_api.register(UserResource()) | |
v1_api.register(FollowResource()) | |
urlpatterns = patterns('pricer.me.views', | |
url(r'', include(v1_api.urls)), | |
url(r'^backbone/$', 'following_list_backbone', name="feed_backbone"), | |
url(r'^$', 'following_list', name="feed") | |
) | |
# | |
# Resources | |
# | |
from tastypie import fields | |
from tastypie.resources import ModelResource | |
from tastypie.authorization import Authorization | |
from django.contrib.auth.models import User | |
from models import Follow, FollowItem | |
class UserResource(ModelResource): | |
class Meta: | |
queryset = User.objects.all() | |
resource_name = 'user' | |
excludes = ['email', 'password', 'is_active', 'is_staff', 'is_superuser'] | |
class FollowResource(ModelResource): | |
class Meta: | |
queryset = Follow.objects.all() | |
# authorization = Authorization() | |
resource_name = 'follow' | |
list_allowed_methods = ['get', 'post'] | |
detail_allowed_methods = ['get'] | |
include_resource_uri = True | |
class FollowItemResource(ModelResource): | |
user = fields.ForeignKey(UserResource, 'user') | |
follow = fields.ForeignKey(FollowResource, 'follow') | |
class Meta: | |
queryset = FollowItem.objects.all() | |
authorization = Authorization() | |
resource_name = 'followItem' | |
list_allowed_methods = ['get', 'post'] | |
detail_allowed_methods = ['get'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment