mirror of
https://github.com/pinry/pinry.git
synced 2025-11-14 00:55:43 +01:00
Rewrite the display of recent pins without the use of third-party js libs
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user