summaryrefslogtreecommitdiff
path: root/app/photos/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/photos/views.py')
-rw-r--r--app/photos/views.py43
1 files changed, 21 insertions, 22 deletions
diff --git a/app/photos/views.py b/app/photos/views.py
index 0c413e0..567f329 100644
--- a/app/photos/views.py
+++ b/app/photos/views.py
@@ -1,45 +1,44 @@
-from django.shortcuts import render_to_response,get_object_or_404
+from django.shortcuts import render_to_response
from django.template import RequestContext
-from django.http import Http404,HttpResponse
+from django.http import Http404, HttpResponse
from django.core import serializers
-
-from photos.models import Photo,PhotoGallery
+from photos.models import Photo, PhotoGallery
from locations.models import Country, Region
-
-
-
-def gallery_list(request,page):
+
+
+def gallery_list(request, page):
request.page_url = '/photos/%d/'
request.page = int(page)
context = {
'object_list': PhotoGallery.objects.all(),
- 'page':page,
- }
- return render_to_response("archives/photos.html", context, context_instance = RequestContext(request))
+ 'page': page,
+ }
+ return render_to_response("archives/photos.html", context, context_instance=RequestContext(request))
-def gallery(request,slug):
+
+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_to_response('details/photo_galleries.html', context, context_instance=RequestContext(request))
+
def photo_json(request, slug):
p = PhotoGallery.objects.filter(set_slug=slug)
return HttpResponse(serializers.serialize('json', p), mimetype='application/json')
-"""
-Grabs entries by region or country
-"""
-def gallery_list_by_area(request,slug,page):
- request.page_url = '/photos/'+slug+'/%d/'
+
+def gallery_list_by_area(request, slug, page):
+ """Grabs entries by region or country"""
+ request.page_url = '/photos/' + slug + '/%d/'
request.page = int(page)
try:
region = Region.objects.get(slug__exact=slug)
- qs = PhotoGallery.objects.filter(region = region).order_by('-id')
+ qs = PhotoGallery.objects.filter(region=region).order_by('-id')
except:
region = Country.objects.get(slug__exact=slug)
- qs = PhotoGallery.objects.filter(location__state__country = region).order_by('-id')
+ qs = PhotoGallery.objects.filter(location__state__country=region).order_by('-id')
if not region:
raise Http404
context = {
@@ -49,4 +48,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_to_response("archives/photos.html", context, context_instance=RequestContext(request))