From 25099bf480cbe8b13852ad45152946819ac4a812 Mon Sep 17 00:00:00 2001 From: lxf Date: Fri, 18 Dec 2020 12:19:52 -0500 Subject: added image resizing back to books --- app/books/kindleparser.py | 8 ++++++++ app/books/models.py | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'app/books') diff --git a/app/books/kindleparser.py b/app/books/kindleparser.py index c56499e..93edfac 100644 --- a/app/books/kindleparser.py +++ b/app/books/kindleparser.py @@ -108,3 +108,11 @@ class KindleClippingsParser(object): body_markdown=body_markdown ) """ + + + + + + + + diff --git a/app/books/models.py b/app/books/models.py index 2ef9716..c003b25 100644 --- a/app/books/models.py +++ b/app/books/models.py @@ -93,14 +93,14 @@ class Book(models.Model): super(Book, self).save() -#@receiver(post_save, sender=Book) +@receiver(post_save, sender=Book) def post_save_events(sender, update_fields, created, instance, **kwargs): 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)) + resize_image(img, None, 160, 78, "%s%s_tn%s" % (base_path, filename.split('/')[-1], file_extension)) + resize_image(img, None, 650, 78, "%s%s_small%s" % (base_path, filename.split('/')[-1], file_extension)) class BookHighlight(models.Model): -- cgit v1.2.3-70-g09d2