From cd52af5c8d93df844db63ef896125a0df34c08c4 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Tue, 28 Aug 2018 09:31:53 -0500 Subject: handled case where I forget to set featured image --- app/jrnl/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/jrnl/models.py b/app/jrnl/models.py index 522764d..6dab4b9 100644 --- a/app/jrnl/models.py +++ b/app/jrnl/models.py @@ -174,8 +174,10 @@ class Entry(models.Model): self.location = Location.objects.filter(geometry__contains=self.point).get() except Location.DoesNotExist: raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) + if created and not self.featured_image: + self.featured_image = LuxImage.objects.latest() old = type(self).objects.get(pk=self.pk) if self.pk else None - if old and old.featured_image != self.featured_image or created: # Field has changed + if old and old.featured_image != self.featured_image: # Field has changed s = LuxImageSize.objects.get(name="featured_jrnl") self.featured_image.sizes.add(s) self.featured_image.save() -- cgit v1.2.3-70-g09d2