diff --git a/gallery/models/album.py b/gallery/models/album.py index 11535b6..66a7935 100644 --- a/gallery/models/album.py +++ b/gallery/models/album.py @@ -22,13 +22,18 @@ class Album(models.Model): def photos_in_album(self): return self.photos.count() + @property + def photos_views(self): + total_views = sum(self.photos.views()) + return total_views + @property def cover_url(self): if self.cover: - return self.cover.photo.url + return self.cover.photo_md.url random_cover = self.photos.order_by('-width').first() if random_cover: - return random_cover.photo.url + return random_cover.photo_md.url return static('img/placeholder.png') def clean(self): diff --git a/gallery/templates/gallery/album_detail.html b/gallery/templates/gallery/album_detail.html index c5ef5ff..cf40a25 100644 --- a/gallery/templates/gallery/album_detail.html +++ b/gallery/templates/gallery/album_detail.html @@ -1,4 +1,6 @@ {% extends "base.html" %} +{% load static %} + {% block title %} Gallery : Albums : {{ album.name }} {% endblock %} @@ -9,19 +11,48 @@