Only use entry.excerpt as a description if it wasn't already used as a title

This commit is contained in:
Danielle McLean 2017-10-27 19:07:28 +11:00
parent d8a6dbf2bf
commit 8853e42508
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

View file

@ -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