diff options
author | luxagraf <sng@luxagraf.net> | 2011-06-16 11:19:49 +0200 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2011-06-16 11:19:49 +0200 |
commit | 9bfe60354ea9ae9fad9de304206b8f41983eaf93 (patch) | |
tree | df0117762e48004ac2bcb9843b47a9bd54ff0e15 /apps/guide/views.py | |
parent | b4d39de7bb6721cac3d7a333aaffd087c311360d (diff) |
created models, db and url structure for new guides section
Diffstat (limited to 'apps/guide/views.py')
-rw-r--r-- | apps/guide/views.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/guide/views.py b/apps/guide/views.py new file mode 100644 index 0000000..dc63fc5 --- /dev/null +++ b/apps/guide/views.py @@ -0,0 +1,34 @@ +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.core.exceptions import ObjectDoesNotExist + +from guide.models import Guide +from locations.models import Location + +def guide_list(request,page): + """ + List of all guides + """ + request.page_url = '/guide/%d/' + request.page = int(page) + qs = Guide.objects.filter(status__exact=1).order_by('-pub_date').select_related() + return object_list(request, queryset=qs, template_name='archives/guide.html', extra_context={'page':page}) + +def guide_list_by_location(request,location): + qs = Guide.objects.filter(location__slug__exact=location) + return object_list(request, queryset=qs, template_name='archives/writing.html') + +def location_list(request): + """ + List of all locations with guides + """ + qs = Guide.objects.filter(status__exact=1).order_by('-pub_date').select_related() + return object_list(request, queryset=qs, template_name='archives/guide.html') + +def guide_detail(request, slug, location=None): + obj = get_object_or_404(Guide, slug__exact=slug) + return render_to_response('details/guide.html', {'object': obj,}, context_instance=RequestContext(request)) + + + |