summaryrefslogtreecommitdiff
path: root/stapp/video/models.py
diff options
context:
space:
mode:
authorParth Buch2012-07-20 15:05:57 +0530
committerParth Buch2012-07-20 15:05:57 +0530
commit09bb2effee9f86ce959c2ed86a3cb28f3561dd7e (patch)
tree88d38a3591f29da988951cb84c6d840db83c0903 /stapp/video/models.py
parentca9d5eadaa5d5e75bc76054da0fcc913d7e33b9b (diff)
downloadstproject-09bb2effee9f86ce959c2ed86a3cb28f3561dd7e.tar.gz
stproject-09bb2effee9f86ce959c2ed86a3cb28f3561dd7e.tar.bz2
stproject-09bb2effee9f86ce959c2ed86a3cb28f3561dd7e.zip
Remove thumbnail field as it was not required
Diffstat (limited to 'stapp/video/models.py')
-rw-r--r--stapp/video/models.py30
1 files changed, 0 insertions, 30 deletions
diff --git a/stapp/video/models.py b/stapp/video/models.py
index 3118c0a..cfbf2aa 100644
--- a/stapp/video/models.py
+++ b/stapp/video/models.py
@@ -8,28 +8,6 @@ import uuid
import datetime
import Image, os
-def handle_thumb(image_obj, thumb_obj, width, height):
- # create thumbnail
- thumb = str(image_obj) + ('-small.jpg')
- try:
- t = Image.open(image_obj.path)
-
- w, h = t.size
- if float(w)/h < float(width)/height:
- t = t.resize((width, h*width/w), Image.ANTIALIAS)
- else:
- t = t.resize((w*height/h, height), Image.ANTIALIAS)
- w, h = t.size
- t = t.crop( ((w-width)/2, (h-height)/4, (w-width)/2+width, \
- (h-height)/4+height) )
-
- t.save(settings.MEDIA_ROOT + thumb, 'JPEG')
- os.chmod(settings.MEDIA_ROOT + thumb, 0666)
- thumb_obj = thumb
- except:
- pass
- return thumb_obj
-
def get_file_path(instance, filename):
ext = filename.split('.')[-1]
@@ -46,20 +24,12 @@ class Video(models.Model):
name = models.CharField(max_length=128)
filename = models.FileField(upload_to=get_file_path)
image = models.ImageField(upload_to=get_image_path)
- thumbnail = models.ImageField(upload_to=get_image_path, \
- blank=True, null=True, editable=False)
description = models.TextField()
created = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return self.name
- def save(self, *args, **kwargs):
- '''On save, generate thumbnails'''
- super(Video, self).save()
- self.thumbnail = handle_thumb(self.image, self.thumbnail, 100, 100)
- super(Video, self).save(force_update=True)
-
#Call the delete_files signal to delete physical files on delete of record
post_delete.connect(delete_files, Video)