summaryrefslogtreecommitdiff
path: root/app/photos
diff options
context:
space:
mode:
Diffstat (limited to 'app/photos')
-rw-r--r--app/photos/models.py5
-rw-r--r--app/photos/views.py13
2 files changed, 13 insertions, 5 deletions
diff --git a/app/photos/models.py b/app/photos/models.py
index 4bf3759..075808d 100644
--- a/app/photos/models.py
+++ b/app/photos/models.py
@@ -153,8 +153,9 @@ class LuxImage(models.Model):
return "%soriginal/%s/%s.%s" % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), base, self.get_image_ext())
else:
if size != 'tn':
- s = LuxImageSize.objects.get(name=size)
- if s not in self.sizes.all():
+ try:
+ self.sizes.filter(name=size)
+ except DoesNotExist:
print("new size is "+s.name)
self.sizes.add(s)
return "%s%s/%s_%s.%s" % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), base, size, self.get_image_ext())
diff --git a/app/photos/views.py b/app/photos/views.py
index 915b022..070b40d 100644
--- a/app/photos/views.py
+++ b/app/photos/views.py
@@ -1,5 +1,5 @@
import json
-from django.shortcuts import render_to_response, render
+from django.shortcuts import render
from django.template import RequestContext
from django.http import Http404, HttpResponse
from django.core import serializers
@@ -64,11 +64,18 @@ class OldGalleryList(PaginatedListView):
class DailyPhotoList(PaginatedListView):
+ model=LuxImage
template_name = 'archives/photo_daily_list.html'
def get_queryset(self):
return LuxImage.objects.filter(is_public=True, title__startswith="daily_")
+ def get_context_data(self, **kwargs):
+ # Call the base implementation first to get a context
+ context = super(DailyPhotoList, self).get_context_data(**kwargs)
+ context['breadcrumbs'] = ['daily',]
+ return context
+
def gallery_list(request, page):
request.page_url = '/photos/%d/'
@@ -84,7 +91,7 @@ def gallery(request, slug):
context = {
'object': PhotoGallery.objects.get(set_slug=slug)
}
- return render_to_response('details/photo_galleries.html', context, context_instance=RequestContext(request))
+ return render(request, 'details/photo_galleries.html', context)
def photo_json(request, slug):
@@ -127,4 +134,4 @@ def gallery_list_by_area(request, slug, page):
'region': region,
'page': page
}
- return render_to_response("archives/photos.html", context, context_instance=RequestContext(request))
+ return render(request, "archives/photos.html", context)