示例#1
0
def main_page_context():
    total_counter = User.objects.filter(is_active=True).count()

    country = Location.objects.country()
    sub_regions = subregion_list(country)
    return {
        'counters': get_roles_counters(Location.objects.country()),
        'total_counter': total_counter,
    }
示例#2
0
文件: views.py 项目: sergkop/grakon

def get_subregions(request):
    if not request.is_ajax():
        return HttpResponse("[]")

    loc_id = request.GET.get("loc_id", "")

    if loc_id:
        try:
            location = Location.objects.get(id=int(loc_id))
        except ValueError, Location.DoesNotExist:
            return HttpResponse("[]")
    else:
        location = None

    return HttpResponse(json.dumps(subregion_list(location), ensure_ascii=False))


# TODO: take tab as a parameter
def goto_location(request):
    loc_id = request.GET.get("loc_id", "")

    try:
        int(loc_id)
    except ValueError:
        return HttpResponseRedirect(reverse("main"))  # TODO: redirect to country page?

    url = reverse("location_tasks", args=[loc_id])
    return HttpResponseRedirect(url)