From 1a048e3dac287325aecc06dd157352b08507f3e7 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sat, 15 Aug 2020 14:34:43 -0400 Subject: changed post save() to extract an image for fieldnotes --- app/posts/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/posts') 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") -- cgit v1.2.3-70-g09d2