diff options
-rw-r--r-- | app/normalize/admin.py | 13 | ||||
-rw-r--r-- | app/normalize/models.py | 4 | ||||
-rw-r--r-- | app/posts/models.py | 4 |
3 files changed, 16 insertions, 5 deletions
diff --git a/app/normalize/admin.py b/app/normalize/admin.py new file mode 100644 index 0000000..cf67658 --- /dev/null +++ b/app/normalize/admin.py @@ -0,0 +1,13 @@ +from django.contrib import admin + +from utils.widgets import AdminImageWidget, LGEntryForm + +from .models import RelatedPost + +@admin.register(RelatedPost) +class RelatedPostAdmin(admin.ModelAdmin): + list_display = ('title', 'slug', 'pub_date', 'model_name') + list_filter = ['model_name'] + + class Media: + js = ('next-prev-links.js',) diff --git a/app/normalize/models.py b/app/normalize/models.py index bcd8eac..f45f90b 100644 --- a/app/normalize/models.py +++ b/app/normalize/models.py @@ -10,8 +10,8 @@ class RelatedPost(models.Model): pub_date = models.DateTimeField('Date published') class Meta: - ordering = ('model_name', '-pub_date',) + ordering = ('-model_name', '-pub_date',) get_latest_by = 'pub_date' def __str__(self): - return self.title + return "%s - %s" % (self.model_name, self.title) diff --git a/app/posts/models.py b/app/posts/models.py index 0c5d74f..d4000d9 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -193,9 +193,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) - related.title = instance.title - related.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_save.disconnect(post_save_events, sender=Post) instance.save() post_save.connect(post_save_events, sender=Post) |