forked from 00dani/lemoncurry
Ensure User.avatar is optional
This commit is contained in:
parent
6b53c00d7c
commit
0061111ad8
2 changed files with 3 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
||||||
<article class="h-entry media">
|
<article class="h-entry media">
|
||||||
{{i}}<aside class="info">
|
{{i}}<aside class="info">
|
||||||
{{i}}<a class="p-author h-card" href="{{ entry.author.url }}">
|
{{i}}<a class="p-author h-card" href="{{ entry.author.url }}">
|
||||||
{{i}}<img class="u-photo img-fluid" src="{{ entry.author.avatar.url }}" alt="{{ entry.author.name }}" />
|
{{i}}{% if entry.author.avatar %}<img class="u-photo img-fluid" src="{{ entry.author.avatar.url }}" alt="{{ entry.author.name }}" />{% endif %}
|
||||||
{{i}}<span class="p-name sr-only">{{ entry.author.name }}</span>
|
{{i}}<span class="p-name sr-only">{{ entry.author.name }}</span>
|
||||||
{{i}}</a>
|
{{i}}</a>
|
||||||
{{i}}<a class="u-uid u-url" href="{{ entry.url }}">
|
{{i}}<a class="u-uid u-url" href="{{ entry.url }}">
|
||||||
|
|
|
@ -128,7 +128,7 @@ class User(ModelMeta, AbstractUser):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def avatar_url(self):
|
def avatar_url(self):
|
||||||
return self.avatar.url
|
return self.avatar.url if self.avatar else None
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def facebook_id(self):
|
def facebook_id(self):
|
||||||
|
@ -154,7 +154,7 @@ class User(ModelMeta, AbstractUser):
|
||||||
"url": self.full_url,
|
"url": self.full_url,
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"email": self.email,
|
"email": self.email,
|
||||||
"image": urljoin(base, self.avatar.url),
|
"image": urljoin(base, self.avatar.url) if self.avatar else None,
|
||||||
"givenName": self.first_name,
|
"givenName": self.first_name,
|
||||||
"familyName": self.last_name,
|
"familyName": self.last_name,
|
||||||
"sameAs": [profile.url for profile in self.profiles.all()],
|
"sameAs": [profile.url for profile in self.profiles.all()],
|
||||||
|
|
Loading…
Reference in a new issue