Make `Photo.author` a @property; None if no author.

master
voussoir 2017-09-23 10:58:04 -07:00
parent 4836efcf23
commit 26a034c9a0
2 changed files with 8 additions and 2 deletions

View File

@ -591,7 +591,13 @@ class Photo(ObjectBase):
albums = [self.photodb.get_album(f[0]) for f in fetch] albums = [self.photodb.get_album(f[0]) for f in fetch]
return albums return albums
@property
def author(self): def author(self):
'''
Return the User object who owns this photo, or None if it is unassigned.
'''
if self.author_id is None:
return None
return self.photodb.get_user(id=self.author_id) return self.photodb.get_user(id=self.author_id)
def bytestring(self): def bytestring(self):

View File

@ -184,8 +184,8 @@
</h4> </h4>
<ul id="metadata"> <ul id="metadata">
<li>Filename: {{photo.basename}}</li> <li>Filename: {{photo.basename}}</li>
{% if photo.author_id %} {% set author = photo.author %}
{% set author = photo.author() %} {% if author is not none %}
<li>Author: <a href="/user/{{author.username}}">{{author.username}}</a></li> <li>Author: <a href="/user/{{author.username}}">{{author.username}}</a></li>
{% endif %} {% endif %}
{% if photo.width %} {% if photo.width %}