sas: fix album preview

Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
Skia 2017-10-06 17:57:35 +02:00
parent 8492903a39
commit 43f51813e0
4 changed files with 8 additions and 4 deletions

View File

@ -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()

View File

@ -40,7 +40,7 @@
<hr>
<h4>{% trans %}All categories{% endtrans %}</h4>
<div>
{% for a in root_file.children.filter(is_folder=True).order_by('date') %}
{% for a in categories %}
{{ display_album(a) }}
{% endfor %}
</div>

View File

@ -32,6 +32,7 @@ urlpatterns = [
url(r'^album/(?P<album_id>[0-9]+)$', AlbumView.as_view(), name='album'),
url(r'^album/(?P<album_id>[0-9]+)/upload$', AlbumUploadView.as_view(), name='album_upload'),
url(r'^album/(?P<album_id>[0-9]+)/edit$', AlbumEditView.as_view(), name='album_edit'),
url(r'^album/(?P<album_id>[0-9]+)/preview$', send_album, name='album_preview'),
url(r'^picture/(?P<picture_id>[0-9]+)$', PictureView.as_view(), name='picture'),
url(r'^picture/(?P<picture_id>[0-9]+)/edit$', PictureEditView.as_view(), name='picture_edit'),
url(r'^picture/(?P<picture_id>[0-9]+)/download$', send_pict, name='download'),

View File

@ -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)