From 9b624d1a5db57c2fafc231b0970a04df0515b0e4 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Wed, 25 Oct 2017 09:34:42 +1100 Subject: [PATCH] Set the twitter:creator and fb:profile_id properties on the homepage --- users/models.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/users/models.py b/users/models.py index e5b65d0..7355bcb 100644 --- a/users/models.py +++ b/users/models.py @@ -27,10 +27,26 @@ class User(ModelMeta, AbstractUser): def avatar_url(self): 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 = { 'image': 'avatar_url', 'description': 'note', 'og_type': 'profile', + 'og_profile_id': 'facebook_id', + 'twitter_creator': 'twitter_username', }