Commits

Guilherme Gondim committed 31ededa

Improve "available_cover"

  • Participants
  • Parent commits 2f829c3

Comments (0)

Files changed (1)

File 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