Rewrite the display of recent pins without the use of third-party js libs

This commit is contained in:
Isaac Bythewood
2013-02-20 07:59:45 +00:00
parent e467a83683
commit 8e8bed0efa
10 changed files with 2368 additions and 139 deletions

View File

@@ -1,15 +1,23 @@
from tastypie.resources import ModelResource
from tastypie import fields
from tastypie.authentication import BasicAuthentication
from tastypie.authorization import DjangoAuthorization
from django.contrib.auth.models import User
from pinry.pins.models import Pin
class UserResource(ModelResource):
class Meta:
queryset = User.objects.all()
resource_name = 'user'
excludes = ['email', 'password', 'is_superuser', 'first_name',
'last_name', 'is_active', 'is_staff', 'last_login', 'date_joined']
include_resource_uri = False
class PinResource(ModelResource): # pylint: disable-msg=R0904
tags = fields.ListField()
submitter = fields.ForeignKey(UserResource, 'submitter', full=True)
class Meta:
queryset = Pin.objects.all()
@@ -17,6 +25,7 @@ class PinResource(ModelResource): # pylint: disable-msg=R0904
include_resource_uri = False
filtering = {
'published': ['gt'],
'submitter': ['exact']
}
def build_filters(self, filters=None):
@@ -37,13 +46,3 @@ class PinResource(ModelResource): # pylint: disable-msg=R0904
tags = bundle.data.get('tags', [])
bundle.obj.tags.set(*tags)
return super(PinResource, self).save_m2m(bundle)
class UserResource(ModelResource):
class Meta:
queryset = User.objects.all()
resource_name = 'auth/user'
excludes = ['email', 'password', 'is_superuser']
# Add it here.
authentication = BasicAuthentication()
authorization = DjangoAuthorization()