Exemplo n.º 1
0
def ajax_count(request):
    if request.is_ajax():
        args = ['-date']
        allowed_ordering = ['priority']
        if 'order' in request.GET and request.GET['order'] in allowed_ordering:
            args.append('-'+request.GET['order'])
        args = reversed(args)
        requests = RequestHistory.objects.order_by(*args)[:10]

        data = {'requests': [ob.as_json() for ob in requests],
                'count': get_unread_requests_count(requests.values_list('id'))}
        return HttpResponse(json.dumps(data), content_type='application/json')
    return HttpResponse(json.dumps({'response': False}),
                        content_type='application/json')
Exemplo n.º 2
0
def request_list(request):
    args = ['-date']
    allowed_ordering = ['priority']
    if 'order' in request.GET and request.GET['order'] in allowed_ordering:
        args.append('-'+request.GET['order'])
    args = reversed(args)
    latest_requests = RequestHistory.objects\
        .order_by(*args)[:10]

    latest_requests_count = \
        get_unread_requests_count(latest_requests.values_list('id'))

    return render_to_response('hello/requests.html',
                              {'latest_requests': latest_requests,
                               'latest_requests_count': latest_requests_count})