summaryrefslogtreecommitdiff
path: root/app/jrnl/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/jrnl/models.py')
-rw-r--r--app/jrnl/models.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py
index dda9d6d..f3734da 100644
--- a/app/jrnl/models.py
+++ b/app/jrnl/models.py
@@ -273,14 +273,17 @@ def cache_gravatar(sender, comment, **kwargs):
urllib.request.urlretrieve(url, local_grav)
-#@receiver(post_save, sender=Entry)
-#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)
-# related.title = instance.title
-# related.slug = instance.slug
-# post_save.disconnect(post_save_events, sender=Entry)
-# instance.save()
-# post_save.connect(post_save_events, sender=Entry)
+@receiver(post_save, sender=Entry)
+def post_save_events(sender, update_fields, created, instance, **kwargs):
+ """
+ Creates a generic related entry when a new post is added
+ """
+ if created:
+ related, c = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pubdate)
+ if c:
+ related.title = instance.title
+ related.slug = instance.slug
+ related.save()
# from django_comments.signals import comment_will_be_posted
# from django_comments import akismet