From 26a034c9a08f40931f2e5f82faf6b268a43df86b Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 23 Sep 2017 10:58:04 -0700 Subject: [PATCH] Make `Photo.author` a @property; None if no author. --- etiquette/objects.py | 6 ++++++ frontends/etiquette_flask/templates/photo.html | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index 0e8fcfb..a0846ce 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -591,7 +591,13 @@ class Photo(ObjectBase): albums = [self.photodb.get_album(f[0]) for f in fetch] return albums + @property 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) def bytestring(self): diff --git a/frontends/etiquette_flask/templates/photo.html b/frontends/etiquette_flask/templates/photo.html index 28e0552..d908640 100644 --- a/frontends/etiquette_flask/templates/photo.html +++ b/frontends/etiquette_flask/templates/photo.html @@ -184,8 +184,8 @@