Beispiel #1
0
def render(request, *args):
    frm = inspect.stack()[1]
    mod = inspect.getmodule(frm[0])

    template = args[0]

    try:
        vars = args[1]
    except:
        vars = {}
        
    try:
        app_name = vars['app_name']
    except:
        app_name = mod.__name__.split('.')[1]
    
    vars['app_name'] = app_name
    vars['base_template'] = get_base_template(request)
    
    users = Visitor.objects.active()
    seen = set()
    seen_add = seen.add
    vars['active_users'] = [ x for x in users if x.user not in seen and not seen_add(x.user)]
    
    request.session['app_name'] = vars['app_name']
    
    return djangorender(request, template, vars)
Beispiel #2
0
def render(request, template, params, *args, formating=True, **kwargs):
    params = {**params, **viewbase(request)}
    if formating:
        format = request.GET.get("format", "html")
        if format != "html":
            params = fixdictforjson(params)

            return HttpResponse(json.dumps(params), content_type="application/json")
        else:
            params = fixdictforjson(params, False)
    return djangorender(request, template, params, *args, **kwargs)
Beispiel #3
0
def render(request, *args):
    frm = inspect.stack()[1]
    mod = inspect.getmodule(frm[0])

    template = args[0]
    
    try:
        vars = args[1]
    except:
        vars = {}
        
    try:
        app_name = vars['app_name']
    except:
        app_name = mod.__name__.split('.')[1]
    
    vars['app_name'] = app_name
    vars['base_template'] = get_base_template(request)
    vars['debug'] = DEBUG

    request.session['app_name'] = vars['app_name']
    
    return djangorender(request, template, vars)