summaryrefslogtreecommitdiff
path: root/app/posts/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/posts/models.py')
-rw-r--r--app/posts/models.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/app/posts/models.py b/app/posts/models.py
index 37c4c9b..7430bf3 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -63,9 +63,18 @@ class Post(models.Model):
(1, 'Published'),
)
status = models.IntegerField(choices=PUB_STATUS, default=0)
- featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True)
- featured_audio = models.ForeignKey(LuxAudio, on_delete=models.CASCADE, null=True, blank=True)
+ featured_image = models.ForeignKey(LuxImage, on_delete=models.SET_NULL, null=True, blank=True)
+ featured_audio = models.ForeignKey(LuxAudio, on_delete=models.SET_NULL, null=True, blank=True)
+ TEMPLATES = (
+ (0, 'single'),
+ (1, 'double'),
+ (2, 'single-dark'),
+ (3, 'double-dark'),
+ (4, 'single-black'),
+ (5, 'double-black'),
+ )
post_type = models.IntegerField(choices=PostType.choices, default=PostType.JRNL)
+ template_name = models.IntegerField(choices=TEMPLATES, default=0)
has_video = models.BooleanField(blank=True, default=False)
has_code = models.BooleanField(blank=True, default=False)
disclaimer = models.BooleanField(blank=True, default=False)
@@ -171,9 +180,9 @@ class Post(models.Model):
prods = render_products(md)
print(self.title)
self.body_html = markdown_to_html(prods)
- if self.epilogue_html:
+ if self.epilogue_markdown:
self.epilogue_html = markdown_to_html(self.epilogue_markdown)
- if self.prologue_html:
+ if self.prologue_markdown:
self.prologue_html = markdown_to_html(self.prologue_markdown)
self.has_video = parse_video(self.body_html)
#if created and not self.featured_image:
@@ -229,7 +238,7 @@ def cache_gravatar(sender, comment, **kwargs):
@receiver(post_save, sender=Post)
def post_save_events(sender, update_fields, created, instance, **kwargs):
- related, created = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pub_date, title=instance.title, slug=instance.slug)
+ related, created = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pub_date, title=instance.title, slug=instance.slug, post_type=instance.get_post_type_display())
post_save.disconnect(post_save_events, sender=Post)
instance.save()
post_save.connect(post_save_events, sender=Post)