From 518b2d618bc10f93cfa44a83715593b8358eb9ce Mon Sep 17 00:00:00 2001 From: luxagraf Date: Fri, 23 May 2014 11:28:10 -0400 Subject: minor refactor to adoipt pep8 and pyflakes coding styles and clean up some cruft that's been hangin round for years --- app/photos/views.py | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'app/photos/views.py') 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)) -- cgit v1.2.3-70-g09d2