Verified Commit e241fb3c authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

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

parent 735514e6
...@@ -167,9 +167,10 @@ class Album(models.Model, metaclass=ModelTranslateMeta): ...@@ -167,9 +167,10 @@ class Album(models.Model, metaclass=ModelTranslateMeta):
@cached_property @cached_property
def cover(self): def cover(self):
cover = None
if self._cover is not None: if self._cover is not None:
return self._cover return self._cover
else: elif self.photo_set.exists():
random.seed(self.dirname) random.seed(self.dirname)
cover = random.choice(self.photo_set.all()) cover = random.choice(self.photo_set.all())
return cover return cover
......
Supports Markdown
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