diff options
Diffstat (limited to 'app/posts')
-rw-r--r-- | app/posts/admin.py | 4 | ||||
-rw-r--r-- | app/posts/models.py | 19 |
2 files changed, 16 insertions, 7 deletions
diff --git a/app/posts/admin.py b/app/posts/admin.py index 27ec145..bed6b1d 100644 --- a/app/posts/admin.py +++ b/app/posts/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin from django import forms -from django.contrib.gis.admin import OSMGeoAdmin +from django.contrib.gis.admin import GISModelAdmin from django.contrib.contenttypes.admin import GenericStackedInline from utils.widgets import AdminImageWidget, LGEntryForm @@ -10,7 +10,7 @@ from utils.util import get_latlon @admin.register(Post) -class PostAdmin(OSMGeoAdmin): +class PostAdmin(GISModelAdmin): form = LGEntryForm def get_queryset(self, request): 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) |