mirror of
https://github.com/pinry/pinry.git
synced 2025-11-13 08:35:41 +01:00
Started implementation of user auth.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
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
|
||||
|
||||
@@ -15,3 +19,13 @@ class PinResource(ModelResource): # pylint: disable-msg=R0904
|
||||
def dehydrate_thumbnail(self, bundle):
|
||||
pin = Pin.objects.only('image').get(pk=bundle.data['id'])
|
||||
return pin.image.url_200x1000
|
||||
|
||||
|
||||
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