mirror of
https://github.com/pinry/pinry.git
synced 2025-11-14 00:55:43 +01:00
Cleaning up code.
This commit is contained in:
@@ -9,8 +9,6 @@ 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'
|
||||
@@ -19,10 +17,6 @@ class PinResource(ModelResource): # pylint: disable-msg=R0904
|
||||
'published': ['gt'],
|
||||
}
|
||||
|
||||
def dehydrate_thumbnail(self, bundle):
|
||||
pin = Pin.objects.only('thumbnail').get(pk=bundle.data['id'])
|
||||
return pin.thumbnail.url
|
||||
|
||||
|
||||
class UserResource(ModelResource):
|
||||
class Meta:
|
||||
|
||||
@@ -27,13 +27,12 @@ class Pin(models.Model):
|
||||
temp_img.write(urllib2.urlopen(self.url).read())
|
||||
temp_img.flush()
|
||||
self.image.save(self.url.split('/')[-1], File(temp_img))
|
||||
else:
|
||||
super(Pin, self).save()
|
||||
|
||||
if not self.thumbnail:
|
||||
if not self.image:
|
||||
image = Image.open(temp_img.name)
|
||||
else:
|
||||
super(Pin, self).save()
|
||||
image = Image.open(self.image.path)
|
||||
size = image.size
|
||||
prop = 200 / image.size[0]
|
||||
|
||||
Reference in New Issue
Block a user