예제 #1
0
파일: views.py 프로젝트: Lapeth/timeline
def listEvents(request):
    isJSON = request.GET.get('f') == "json"
    (events, pagination) = Query.listEvents(request, isJSON)
    
    if isJSON:
        return HttpResponse(JSONSerializer().serialize(events))
    
    path = "/event/"
    if len(request.GET):
        i = 0
        for key in request.GET:
            if key != 'p':
                value = request.GET[key]
                if not isinstance(value, list):
                    value = [value]
                for v in value:
                    path += "&" if i > 0 else "?";
                    path += key + "=" + v
                    i += 1
        ppath = path + ("?" if i == 0 else "&")
    else:
        ppath = "?"
        
    query = Query.getQuery(request)
    
    data = {
        "events":events,
        "nav":"events",
        "pagination": pagination,
        "query": query or '',
        "path": path,
        "ppath": ppath
    }
    data["user"] = request.user
    data["permissions"] = request.user.get_all_permissions()
    data["languages"] = Query.listLanguages()
    data["language"] = request.GET.get("l")
    return render(request, "events.html", data, context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: Lapeth/timeline
def listEvents(request):
    (events,p) = Query.listEvents(request, True)
    return HttpResponse(JSONSerializer().serialize(events))