summaryrefslogtreecommitdiff
path: root/app/posts
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-08-15 14:34:43 -0400
committerluxagraf <sng@luxagraf.net>2020-08-15 14:34:43 -0400
commit1a048e3dac287325aecc06dd157352b08507f3e7 (patch)
treea91eae913d09a1bcbb35113af6fad788a9b15170 /app/posts
parenteaa8b13fb802cf2135f91ef108df8875d4ca18b2 (diff)
changed post save() to extract an image for fieldnotes
Diffstat (limited to 'app/posts')
-rw-r--r--app/posts/models.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/posts/models.py b/app/posts/models.py
index 31e96b0..196c941 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -168,7 +168,10 @@ class Post(models.Model):
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()
+ if self.post_type == PostType.FIELD_NOTE:
+ self.featured_image = extract_main_image(self.body_markdown)
+ else:
+ 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: # Field has changed
s = LuxImageSize.objects.get(name="featured_jrnl")