Commit 2c452863 authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'fix/photos-api-cover' into 'master'

Allow the album cover to return None when the album has no images

See merge request !796
parents b527cccd e241fb3c
......@@ -167,9 +167,10 @@ class Album(models.Model, metaclass=ModelTranslateMeta):
def cover(self):
cover = None
if self._cover is not None:
return self._cover
elif self.photo_set.exists():
cover = random.choice(self.photo_set.all())
return cover
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment