Set the twitter:creator and fb:profile_id properties on the homepage

This commit is contained in:
Danielle McLean 2017-10-25 09:34:42 +11:00
parent 0328ab97f6
commit 9b624d1a5d
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

View file

@ -27,10 +27,26 @@ class User(ModelMeta, AbstractUser):
def avatar_url(self): def avatar_url(self):
return self.avatar.url return self.avatar.url
@property
def facebook_id(self):
try:
return self.profiles.filter(site__name='Facebook')[0].username
except IndexError:
return None
@property
def twitter_username(self):
try:
return '@' + self.profiles.filter(site__name='Twitter')[0].username
except IndexError:
return None
_metadata = { _metadata = {
'image': 'avatar_url', 'image': 'avatar_url',
'description': 'note', 'description': 'note',
'og_type': 'profile', 'og_type': 'profile',
'og_profile_id': 'facebook_id',
'twitter_creator': 'twitter_username',
} }