questionnaire.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:eq-survey-runner 作者: ONSdigital 项目源码 文件源码
def _get_context(full_routing_path, block, current_location, form):
    metadata = get_metadata(current_user)
    answer_store = get_answer_store(current_user)
    schema_context = _get_schema_context(full_routing_path, current_location, metadata, answer_store)

    variables = g.schema_json.get('variables')
    if variables:
        variables = renderer.render(variables, **schema_context)

    if block['type'] == 'Summary':
        rendered_schema_json = renderer.render(g.schema_json, **schema_context)
        form = form or FlaskForm()
        summary_rendered_context = build_summary_rendering_context(rendered_schema_json, answer_store, metadata)
        context = {'form': form, 'summary': summary_rendered_context, 'variables': variables}
        return context

    block = renderer.render(block, **schema_context)
    context = {'block': block, 'variables': variables}

    if not form:
        error_messages = SchemaHelper.get_messages(g.schema_json)
        form, template_params = get_form_for_location(block, current_location, answer_store, error_messages)
        if template_params:
            context.update(template_params)

    context['form'] = form

    return context
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号