Ejemplo n.º 1
0
def location_details(request, location_pk):
    """Supply location details view"""
    loc = get_object_or_404(Location.objects.select_related(depth=3),
                            pk=location_pk)

    # this is sneaky, but allows us to access this list from
    # template tags without doing extra querying.
    loc.active_requests = SupplyRequest.active().filter(location=loc)
    return render_to_response(request, "supply/single_location.html",
                              {"location": loc})
Ejemplo n.º 2
0
def dashboard(request):
    """Supply dashboard"""
    active_requests = SupplyRequest.active().order_by("-created").order_by(
        "location")
    locations = set((req.location for req in active_requests))
    for location in locations:
        location.active_requests = active_requests.filter(location=location)
    return render_to_response(request, "supply/dashboard.html", {
        "active_requests": active_requests,
        "locations": locations
    })