forked from overshard/pinry
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now using tastypie for all our API needs.
- Loading branch information
Showing
9 changed files
with
31 additions
and
30 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from tastypie.resources import ModelResource | ||
from tastypie import fields | ||
|
||
from pinry.pins.models import Pin | ||
|
||
|
||
class PinResource(ModelResource): | ||
thumbnail = fields.CharField(readonly=True) | ||
|
||
class Meta: | ||
queryset = Pin.objects.all() | ||
resource_name = 'pin' | ||
include_resource_uri = False | ||
|
||
def dehydrate_thumbnail(self, bundle): | ||
return Pin.objects.only('image').get(pk=bundle.data['id']).image.url_200x1000 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
from django.conf.urls import patterns, include, url | ||
from .api import PinResource | ||
|
||
pin_resource = PinResource() | ||
|
||
urlpatterns = patterns('', | ||
url(r'^pins/recent/(?P<page>\d*)/$', 'pinry.api.views.pins_recent', name='pins-recent'), | ||
url(r'', include(pin_resource.urls)), | ||
) |
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Django==1.4 | ||
South==0.7.4 | ||
PIL==1.1.7 | ||
django-tastypie==0.9.11 | ||
git+git://github.com/vannoppen/django-thumbs.git@v1.0.0#egg=django-thumbs |
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