diff options
author | luxagraf <sng@luxagraf.net> | 2018-08-28 09:31:53 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2018-08-28 09:31:53 -0500 |
commit | cd52af5c8d93df844db63ef896125a0df34c08c4 (patch) | |
tree | f2e7dcab4dbf47cc5e43b0c640fab925ca3cc33b | |
parent | 3834d7958306773af8be002087bb83260129fa08 (diff) |
handled case where I forget to set featured image
-rw-r--r-- | app/jrnl/models.py | 4 |
1 files changed, 3 insertions, 1 deletions
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() |