diff options
Diffstat (limited to 'app/sightings/models.py')
-rw-r--r-- | app/sightings/models.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/app/sightings/models.py b/app/sightings/models.py index dfcde2c..ecf28a2 100644 --- a/app/sightings/models.py +++ b/app/sightings/models.py @@ -63,6 +63,7 @@ class AP(models.Model): body_html = models.TextField(null=True, blank=True) body_markdown = models.TextField(null=True, blank=True) featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True) + have_seen = models.BooleanField(default=False) # image = models.FileField(upload_to=get_upload_path, null=True, blank=True, help_text="width of high res is 1360px") # image_credit = models.CharField(max_length=200, blank=True, null=True) @@ -116,15 +117,20 @@ class AP(models.Model): def save(self, *args, **kwargs): if self.pk: - md = render_images(self.body_markdown) - self.body_html = markdown_to_html(md) - main_image = extract_main_image(self.body_markdown) - if main_image: - self.image = main_image - s = LuxImageSize.objects.get(name="featured_jrnl") - self.image.sizes.add(s) - self.image.save() + try: + md = render_images(self.body_markdown) + self.body_html = markdown_to_html(md) + main_image = extract_main_image(self.body_markdown) + if main_image: + self.image = main_image + s = LuxImageSize.objects.get(name="featured_jrnl") + self.image.sizes.add(s) + self.image.save() + except: + pass self.slug = slugify(self.common_name[:50]) + if self.seen == True: + self.have_seen = True super(AP, self).save(*args, **kwargs) |