summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/media/models.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/app/media/models.py b/app/media/models.py
index 89e710a..f50af8a 100644
--- a/app/media/models.py
+++ b/app/media/models.py
@@ -202,12 +202,6 @@ class LuxImage(models.Model):
return False
def save(self, *args, **kwargs):
- created = self.pk is None
- if created:
- self.sizes.add(LuxImageSize.objects.get(slug="tn"))
- img = Image.open(self.image.path)
- self.height = img.height
- self.width = img.width
self.sizes_cache = ",".join(s.slug for s in self.sizes.all())
super(LuxImage, self).save()
@@ -345,6 +339,19 @@ class LuxAudio(models.Model):
super(LuxAudio, self).save(*args, **kwargs)
+@receiver(post_save, sender=LuxImage)
+def post_save_events(sender, update_fields, created, instance, **kwargs):
+ if created:
+ if instance.exif_raw == '':
+ instance = readexif(instance)
+ instance.sizes.add(LuxImageSize.objects.get(slug="tn"))
+ img = Image.open(instance.image.path)
+ instance.height = img.height
+ instance.width = img.width
+ post_save.disconnect(post_save_events, sender=LuxImage)
+ instance.save()
+ post_save.connect(post_save_events, sender=LuxImage)
+
@receiver(m2m_changed, sender=LuxImage.sizes.through)
def update_photo_sizes(sender, instance, **kwargs):