From 1c656d42f8f00b7202621c1aa392d718dcc6c7cd Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 26 Sep 2016 22:55:41 -0400 Subject: enabled public galleries new style --- app/photos/urls.py | 14 ++++++++++++-- app/photos/views.py | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app/photos/urls.py b/app/photos/urls.py index 67375da..5978107 100644 --- a/app/photos/urls.py +++ b/app/photos/urls.py @@ -25,8 +25,18 @@ urlpatterns = [ RedirectView.as_view(url="/photos/galleries/private/1/", permanent=False) ), url( - r'galleries/(?P[-\w]+)/$', - views.gallery, + r'galleries/(?P[-\w]+)$', + views.Gallery.as_view(), + name="private" + ), + url( + r'galleries/(?P\d+)/$', + views.GalleryList.as_view(), + name="private_list" + ), + url( + r'galleries/$', + RedirectView.as_view(url="/photos/galleries/1/", permanent=False) ), url( r'(?P\d+)/$', diff --git a/app/photos/views.py b/app/photos/views.py index 4b89e4c..bb94fbe 100644 --- a/app/photos/views.py +++ b/app/photos/views.py @@ -29,6 +29,25 @@ class PrivateGalleryList(PaginatedListView): context['is_private'] = True return context +class Gallery(DetailView): + model = LuxGallery + slug_field = "slug" + template_name = "details/photo_gallery.html" + + +class GalleryList(PaginatedListView): + template_name = 'archives/gallery_list.html' + + def get_queryset(self): + return LuxGallery.objects.filter(is_public=True) + + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(GalleryList, self).get_context_data(**kwargs) + context['is_private'] = False + return context + + def gallery_list(request, page): request.page_url = '/photos/%d/' request.page = int(page) -- cgit v1.2.3