diff options
author | luxagraf <sng@luxagraf.net> | 2018-09-27 11:33:59 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2018-09-27 11:33:59 -0500 |
commit | 1596c642731e5839da942c7727bbc1fa8016fdee (patch) | |
tree | c8630e2332d4e40a3335a67f1931462eb020c700 /app/photos | |
parent | efabaed1ef7ec2baafabed9dfd3c08dc192d98bd (diff) |
version 9 of stylesheet
Diffstat (limited to 'app/photos')
-rw-r--r-- | app/photos/models.py | 4 | ||||
-rw-r--r-- | app/photos/urls.py | 28 | ||||
-rw-r--r-- | app/photos/views.py | 17 |
3 files changed, 31 insertions, 18 deletions
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<slug>[-\w]+)/$', + path( + r'data/(<str:slug>/$', views.photo_json ), - url( + re_path( r'data/admin/preview/(?P<pk>\d+)/$', views.photo_preview_json, name="admin_image_preview" ), - url( + re_path( r'data/admin/tn/(?P<pk>\d+)/$', views.thumb_preview_json, name="admin_thumb_preview" ), - url( + re_path( r'galleries/private/(?P<slug>[-\w]+)$', views.PrivateGallery.as_view(), name="private" ), - url( + re_path( r'galleries/private/(?P<page>\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<slug>[-\w]+)$', views.Gallery.as_view(), name="private" ), - url( + re_path( r'galleries/(?P<page>\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<page>\d+)/$', views.gallery_list, ), - url( + re_path( r'(?P<slug>[-\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): |