summaryrefslogtreecommitdiff
path: root/app/books
diff options
context:
space:
mode:
authorGitea <gitea@fake.local>2020-04-29 02:15:31 +0000
committerGitea <gitea@fake.local>2020-04-29 02:15:31 +0000
commitafe50e464d76690fc1fa7c6d72c0d6d7e743a527 (patch)
treeea2b277ddc3d9aaba2ffd3e92ebdcd5c5e6ce51f /app/books
parent9ce8f0ef97d06750c323785828620becf375058f (diff)
adding stuff from live server
Diffstat (limited to 'app/books')
-rw-r--r--app/books/models.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/books/models.py b/app/books/models.py
index 8e8b485..eafa9be 100644
--- a/app/books/models.py
+++ b/app/books/models.py
@@ -94,11 +94,12 @@ class Book(models.Model):
@receiver(post_save, sender=Book)
def post_save_events(sender, update_fields, created, instance, **kwargs):
- base_path = "%s/%s/" % (settings.MEDIA_ROOT, "/".join(str(i) for i in instance.image.name.split('/')[:-1]))
- filename, file_extension = os.path.splitext(instance.image.path)
- img = Image.open(instance.image.path)
- resize_image(img, None, 160, 78, base_path, "%s_tn%s" % (filename.split('/')[-1], file_extension))
- resize_image(img, None, 650, 78, base_path, "%s_small%s" % (filename.split('/')[-1], file_extension))
+ if instance.image:
+ base_path = "%s/%s/" % (settings.MEDIA_ROOT, "/".join(str(i) for i in instance.image.name.split('/')[:-1]))
+ filename, file_extension = os.path.splitext(instance.image.path)
+ img = Image.open(instance.image.path)
+ resize_image(img, None, 160, 78, base_path, "%s_tn%s" % (filename.split('/')[-1], file_extension))
+ resize_image(img, None, 650, 78, base_path, "%s_small%s" % (filename.split('/')[-1], file_extension))
class BookHighlight(models.Model):