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):
@cached_property
def cover(self):
cover = None
if self._cover is not None:
return self._cover
else:
elif self.photo_set.exists():
random.seed(self.dirname)
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