diff options
author | luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f> | 2009-01-05 04:07:10 +0000 |
---|---|---|
committer | luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f> | 2009-01-05 04:07:10 +0000 |
commit | 637d71d2c3a7c1c65a931e1eb094052a095cdf05 (patch) | |
tree | ca34a2fead939b133143ec7647a9437d52c89075 /apps/photos/views.py |
have at it
Diffstat (limited to 'apps/photos/views.py')
-rw-r--r-- | apps/photos/views.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/apps/photos/views.py b/apps/photos/views.py new file mode 100644 index 0000000..23efbde --- /dev/null +++ b/apps/photos/views.py @@ -0,0 +1,49 @@ +from django.shortcuts import render_to_response,get_object_or_404 +from django.template import RequestContext +from django.views.generic.list_detail import object_list +from django.http import Http404 + +from tagging.models import Tag,TaggedItem +from photos.models import Photo,PhotoGallery +from locations.models import Country, Region + +def potd_list(request): + potd_obj = Tag.objects.filter(name__exact='potd') + qs = TaggedItem.objects.get_by_model(Photo, potd_obj) + return render_to_response('photos/photo-of-the-day.html', {'object_list': qs,}) + + + +def gallery_list(request,page): + request.page_url = '/photos/%d/' + request.page = int(page) + qs = PhotoGallery.objects.all().order_by('-id') + context = { + 'country_list': Country.objects.filter(visited=True), + 'region_list': Region.objects.all() + } + return object_list(request, queryset=qs, template_name='archives/photos.html', + extra_context=context) + + +""" +Grabs entries by region or country +""" +def gallery_list_by_area(request,slug,page): + 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') + except: + region = Country.objects.get(slug__exact=slug) + qs = PhotoGallery.objects.filter(location__state__country = region).order_by('-id') + if not region: + raise Http404 + context = { + 'region': region, + 'country_list': Country.objects.filter(visited=True), + 'region_list': Region.objects.all() + } + return object_list(request, queryset=qs, template_name='archives/photos.html', + extra_context=context) |