summaryrefslogtreecommitdiff
path: root/app/guide/views.py
blob: c22a6b33862cc84f5d8626484369b0d3164f37eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext

from guide.models import Guide


def guide_list(request, page):
    """List of all guides"""
    request.page_url = "/guide/%d/"
    request.page = int(page)
    context = {
        'object_list': Guide.objects.filter(status__exact=1).order_by('-pub_date').select_related(),
        'page': page,
    }
    return render_to_response("archives/guide.html", context, context_instance=RequestContext(request))


def guide_list_by_location(request, location):
    context = {
        "object_list": Guide.objects.filter(location__slug__exact=location),
    }
    return render_to_response("archives/guide.html", context, context_instance=RequestContext(request))


def location_list(request):
    """List of all locations with guides"""
    context = {
        "object_list": Guide.objects.filter(status__exact=1).order_by('-pub_date').select_related()
    }
    return render_to_response("archives/guide.html", context, context_instance=RequestContext(request))


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))