diff --git a/sas/models.py b/sas/models.py
index 583c3f59..f274ab93 100644
--- a/sas/models.py
+++ b/sas/models.py
@@ -153,7 +153,7 @@ class Album(SithFile):
return reverse('sas:album', kwargs={'album_id': self.id})
def get_download_url(self):
- return reverse('sas:download', kwargs={'picture_id': self.id})
+ return reverse('sas:album_preview', kwargs={'album_id': self.id})
def generate_thumbnail(self):
p = self.children_pictures.order_by('?').first() or self.children_albums.exclude(file=None).exclude(file="").order_by('?').first()
diff --git a/sas/templates/sas/main.jinja b/sas/templates/sas/main.jinja
index db14bb86..3982bf47 100644
--- a/sas/templates/sas/main.jinja
+++ b/sas/templates/sas/main.jinja
@@ -40,7 +40,7 @@
{% trans %}All categories{% endtrans %}
- {% for a in root_file.children.filter(is_folder=True).order_by('date') %}
+ {% for a in categories %}
{{ display_album(a) }}
{% endfor %}
diff --git a/sas/urls.py b/sas/urls.py
index 0a204e69..e4804292 100644
--- a/sas/urls.py
+++ b/sas/urls.py
@@ -32,6 +32,7 @@ urlpatterns = [
url(r'^album/(?P[0-9]+)$', AlbumView.as_view(), name='album'),
url(r'^album/(?P[0-9]+)/upload$', AlbumUploadView.as_view(), name='album_upload'),
url(r'^album/(?P[0-9]+)/edit$', AlbumEditView.as_view(), name='album_edit'),
+ url(r'^album/(?P[0-9]+)/preview$', send_album, name='album_preview'),
url(r'^picture/(?P[0-9]+)$', PictureView.as_view(), name='picture'),
url(r'^picture/(?P[0-9]+)/edit$', PictureEditView.as_view(), name='picture_edit'),
url(r'^picture/(?P[0-9]+)/download$', send_pict, name='download'),
diff --git a/sas/views.py b/sas/views.py
index ed8668e1..b7df29a6 100644
--- a/sas/views.py
+++ b/sas/views.py
@@ -99,8 +99,8 @@ class SASMainView(FormView):
def get_context_data(self, **kwargs):
kwargs = super(SASMainView, self).get_context_data(**kwargs)
- kwargs['root_file'] = SithFile.objects.filter(id=settings.SITH_SAS_ROOT_DIR_ID).first()
- kwargs['latest'] = SithFile.objects.filter(is_in_sas=True, is_folder=True, is_moderated=True).order_by('-id')[:5]
+ kwargs['categories'] = Album.objects.filter(parent__id=settings.SITH_SAS_ROOT_DIR_ID).order_by('date')
+ kwargs['latest'] = Album.objects.filter(is_moderated=True).order_by('-id')[:5]
return kwargs
@@ -159,6 +159,9 @@ class PictureView(CanViewMixin, DetailView, FormMixin):
return reverse('sas:picture', kwargs={'picture_id': self.object.id})
+def send_album(request, album_id):
+ return send_file(request, album_id, Album)
+
def send_pict(request, picture_id):
return send_file(request, picture_id, Picture)