From 8853e42508e98483ea0bef6fc8322dc76833db00 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Fri, 27 Oct 2017 19:07:28 +1100 Subject: [PATCH] Only use entry.excerpt as a description if it wasn't already used as a title --- entries/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/entries/models.py b/entries/models.py index dcdae7f..4bb4454 100644 --- a/entries/models.py +++ b/entries/models.py @@ -40,7 +40,7 @@ class Entry(ModelMeta, models.Model): updated = models.DateTimeField() _metadata = { - 'description': 'excerpt', + 'description': 'excerpt_if_unused', 'image': 'image_url', 'twitter_creator': 'twitter_creator', 'og_profile_id': 'og_profile_id', @@ -55,6 +55,11 @@ class Entry(ModelMeta, models.Model): first_line = self.content.split('\n')[0] return shorten(first_line, width=100, placeholder='…') + @property + def excerpt_if_unused(self): + if self.name: + return self.excerpt + @property def twitter_creator(self): return self.author.twitter_username