Commits

Guilherme Gondim committed 31ededa

Improve "available_cover"

Comments (0)

Files changed (1)

galeria/models.py

     def available_cover(self):
         if self.cover:
             return self.cover
+        elif getattr(self, '_cover', None):
+            return self._cover
         elif self.pictures.public():
-            return self.pictures.public().order_by('?')[0]
+            self._cover = self.pictures.public().order_by('?')[0]
+            return self._cover
         else:
             return None