mirror of
https://github.com/pinry/pinry.git
synced 2025-11-13 16:45:41 +01:00
18 lines
490 B
Python
18 lines
490 B
Python
from tastypie.resources import ModelResource
|
|
from tastypie import fields
|
|
|
|
from pinry.pins.models import Pin
|
|
|
|
|
|
class PinResource(ModelResource): # pylint: disable-msg=R0904
|
|
thumbnail = fields.CharField(readonly=True)
|
|
|
|
class Meta:
|
|
queryset = Pin.objects.all()
|
|
resource_name = 'pin'
|
|
include_resource_uri = False
|
|
|
|
def dehydrate_thumbnail(self, bundle):
|
|
pin = Pin.objects.only('image').get(pk=bundle.data['id'])
|
|
return pin.image.url_200x1000
|