예제 #1
0
파일: crispy.py 프로젝트: GaretJax/csat
    def _render(self, context, form, helper, caller):
        if helper is None:
            helper = crispy.FormHelper() if not hasattr(form, 'helper') else form.helper

        is_formset = isinstance(form, BaseFormSet)
        node_context = Context(context.get_all())
        node = crispy.BasicNode(form, helper)
        context_dict = node.get_response_dict(helper, node_context, is_formset)

        node_context.update(context_dict)

        if helper and helper.layout:
            if not is_formset:
                form.form_html = helper.render_layout(form, node_context, template_pack=crispy.TEMPLATE_PACK)
            else:
                forloop = crispy.ForLoopSimulator(form)
                for f in form.forms:
                    node_context.update({'forloop': forloop})
                    form.form_html = helper.render_layout(f, node_context, template_pack=crispy.TEMPLATE_PACK)
                    forloop.iterate()

        if is_formset:
            context_dict.update({'formset': form})
        else:
            context_dict.update({'form': form})

        context = Context(context_dict)

        if context['is_formset']:
            template = crispy.whole_uni_formset_template(crispy.TEMPLATE_PACK)
        else:
            template = crispy.whole_uni_form_template(crispy.TEMPLATE_PACK)

        return template.render(context)
예제 #2
0
def render_into_skin(template, data, request, mimetype = 'text/html'):
    """in the future this function will be able to
    switch skin depending on the site administrator/user selection
    right now only admins can switch
    """
    context = RequestContext(request, data)
    template = get_template(template, request)
    return HttpResponse(template.render(context), mimetype = mimetype)
예제 #3
0
def render_into_skin(template, data, request, mimetype = 'text/html'):
    """in the future this function will be able to
    switch skin depending on the site administrator/user selection
    right now only admins can switch
    """
    context = RequestContext(request, data)
    template = get_template(template, request)
    return HttpResponse(template.render(context), mimetype = mimetype)
예제 #4
0
def render_text_into_skin(text, data, request):
    context = RequestContext(request, data)
    skin = get_skin(request)
    template = skin.from_string(text)
    return template.render(context)
예제 #5
0
def render_into_skin_as_string(template, data, request):
    context = RequestContext(request, data)
    template = get_template(template, request)
    return template.render(context)
예제 #6
0
def render_text_into_skin(text, data, request):
    context = RequestContext(request, data)
    skin = get_skin(request)
    template = skin.from_string(text)
    return template.render(context)
예제 #7
0
def render_into_skin_as_string(template, data, request):
    context = RequestContext(request, data)
    template = get_template(template, request)
    return template.render(context)