From 1596c642731e5839da942c7727bbc1fa8016fdee Mon Sep 17 00:00:00 2001 From: luxagraf Date: Thu, 27 Sep 2018 11:33:59 -0500 Subject: version 9 of stylesheet --- app/photos/models.py | 4 ++-- app/photos/urls.py | 28 ++++++++++++++-------------- app/photos/views.py | 17 +++++++++++++++-- 3 files changed, 31 insertions(+), 18 deletions(-) (limited to 'app/photos') diff --git a/app/photos/models.py b/app/photos/models.py index 5a41182..9f78ac9 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -179,7 +179,7 @@ class LuxImage(models.Model): self.location = apps.get_model('locations', 'Location').objects.filter( geometry__contains=self.point ).get() - except DoesNotExist: + except apps.get_model('locations', 'Location').DoesNotExist: raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) super(LuxImage, self).save() @@ -337,7 +337,7 @@ class Photo(models.Model): return '%sflickr/med/%s/%s.jpg' % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), self.flickr_id) def get_local_orig_url(self): - return '%sflickr/full/%s/%s.jpg' % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), self.flickr_id) + return '%s/flickr/full/%s/%s.jpg' % (settings.IMAGES_ROOT, self.pub_date.strftime("%Y"), self.flickr_id) def get_local_slideshow_url(self): return '%sslideshow/%s/%s.jpg' % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), self.flickr_id) diff --git a/app/photos/urls.py b/app/photos/urls.py index 1da29a6..8c51d60 100644 --- a/app/photos/urls.py +++ b/app/photos/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.urls import path, re_path from django.views.generic.base import RedirectView from . import views @@ -6,57 +6,57 @@ from . import views app_name = "photos" urlpatterns = [ - url( - r'data/(?P[-\w]+)/$', + path( + r'data/(/$', views.photo_json ), - url( + re_path( r'data/admin/preview/(?P\d+)/$', views.photo_preview_json, name="admin_image_preview" ), - url( + re_path( r'data/admin/tn/(?P\d+)/$', views.thumb_preview_json, name="admin_thumb_preview" ), - url( + re_path( r'galleries/private/(?P[-\w]+)$', views.PrivateGallery.as_view(), name="private" ), - url( + re_path( r'galleries/private/(?P\d+)/$', views.PrivateGalleryList.as_view(), name="private_list" ), - url( + re_path( r'galleries/private/$', RedirectView.as_view(url="/photos/galleries/private/1/", permanent=False) ), - url( + re_path( r'galleries/(?P[-\w]+)$', views.Gallery.as_view(), name="private" ), - url( + re_path( r'galleries/(?P\d+)/$', views.GalleryList.as_view(), name="private_list" ), - url( + re_path( r'galleries/$', RedirectView.as_view(url="/photos/galleries/1/", permanent=False) ), - url( + re_path( r'(?P\d+)/$', views.gallery_list, ), - url( + re_path( r'(?P[-\w]+)/$', RedirectView.as_view(url="/photos/%(slug)s/1/", permanent=False) ), - url( + re_path( r'', RedirectView.as_view(url="/photos/1/", permanent=False) ), diff --git a/app/photos/views.py b/app/photos/views.py index 87cc996..ec4ba61 100644 --- a/app/photos/views.py +++ b/app/photos/views.py @@ -1,5 +1,5 @@ import json -from django.shortcuts import render_to_response +from django.shortcuts import render_to_response, render from django.template import RequestContext from django.http import Http404, HttpResponse from django.core import serializers @@ -49,6 +49,19 @@ class GalleryList(PaginatedListView): return context +class OldGalleryList(PaginatedListView): + template_name = 'archives/gallery_list.html' + model = PhotoGallery + + def get_queryset(self): + return PhotoGallery.objects.filter(is_public=True) + + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(OldGalleryList, self).get_context_data(**kwargs) + return context + + def gallery_list(request, page): request.page_url = '/photos/%d/' request.page = int(page) @@ -56,7 +69,7 @@ def gallery_list(request, page): 'object_list': PhotoGallery.objects.all(), 'page': page, } - return render_to_response("archives/photos.html", context, context_instance=RequestContext(request)) + return render(request, "archives/photos.html", context) def gallery(request, slug): -- cgit v1.2.3-70-g09d2