예제 #1
0
def render_template(path, *args, **kwargs):
    """Identical to flask's render_template, but loads from the active theme if
    one is available.
    """
    try:
        return flask_render_template(lookup_theme_path(path), *args, **kwargs)
    except TemplateNotFound:
        return flask_render_template(path, *args, **kwargs)
예제 #2
0
def render_template(path, **kwargs):
    return flask_render_template(
        path, **{
            'opts': config,
            'macros': macros,
            **kwargs
        })
예제 #3
0
파일: flask.py 프로젝트: zedoax/conditional
def render_template(request, template_name, **kwargs):
    user_name = request.headers.get('x-webauth-user')

    # TODO maybe use the webauth request decorator

    if EvalSettings.query.first() is None:
        db.session.add(EvalSettings())
        db.session.flush()
        db.session.commit()

    lockdown = EvalSettings.query.first().site_lockdown
    is_active = ldap_is_active(user_name)
    is_alumni = ldap_is_alumni(user_name)
    is_eboard = ldap_is_eboard(user_name)
    is_financial = ldap_is_financial_director(user_name)
    is_eval = ldap_is_eval_director(user_name)
    is_intromember = ldap_is_intromember(user_name)

    if is_eval:
        lockdown = False

    return flask_render_template(template_name,
                                 lockdown=lockdown,
                                 is_active=is_active,
                                 is_alumni=is_alumni,
                                 is_eboard=is_eboard,
                                 is_eval_director=is_eval,
                                 is_financial_director=is_financial,
                                 is_intromember=is_intromember,
                                 **kwargs)
예제 #4
0
파일: utils.py 프로젝트: zky001/me
def render_template(template_name_or_list, **context):
    """add "user" and "settings" for every response"""
    context.update({
        "user": User.get_current_user(),
        "settings": get_site_settings(),
    })
    return flask_render_template(template_name_or_list, **context)
예제 #5
0
def render_template(template_name, **context):
    new_context = {"config": config, "is_admin_login": "******" in session and session["username"] == config.USERNAME}
    for k, v in context.iteritems():
        if k not in new_context:
            new_context[k] = v

    return flask_render_template(template_name, **new_context)
예제 #6
0
def render_template(template, **kwargs):
    template = f"{template.lower()}.html"
    theme = cookie_session.get("theme")
    survey_title = lazy_gettext("Census 2021")
    page_header_context = get_page_header_context(get_locale().language, theme
                                                  or "census")
    page_header_context.update({"title": survey_title})
    google_tag_manager_context = get_google_tag_manager_context()
    cdn_url = f'{current_app.config["CDN_URL"]}{current_app.config["CDN_ASSETS_PATH"]}'
    contact_us_url = get_contact_us_url(theme, get_locale().language)
    include_csrf_token = request.url_rule and "POST" in request.url_rule.methods
    account_service_url = cookie_session.get("account_service_url",
                                             f"{CENSUS_BASE_URL}en/start")

    return flask_render_template(
        template,
        account_service_url=account_service_url,
        account_service_log_out_url=cookie_session.get(
            "account_service_log_out_url"),
        contact_us_url=contact_us_url,
        cookie_settings_url=current_app.config["COOKIE_SETTINGS_URL"],
        page_header=page_header_context,
        theme=_map_theme(theme),
        languages=get_languages_context(),
        schema_theme=theme,
        language_code=get_locale().language,
        survey_title=survey_title,
        cdn_url=cdn_url,
        address_lookup_api_url=current_app.config["ADDRESS_LOOKUP_API_URL"],
        data_layer=get_data_layer(theme),
        include_csrf_token=include_csrf_token,
        sign_out_url=url_for("session.get_sign_out"),
        **google_tag_manager_context,
        **kwargs,
    )
예제 #7
0
def render_template(template_name, **context):
    '''
    Render a template from a given name and context. In contrast to  flask's
    original render_template function this looks for the template file within
    the theme folder. This theme folder is configured in the BLOG_THEME
    configuration key.

    :param template_name: template to render
    :param context: given context for variables in template
    :return: rendered HTML output
    '''
    if 'BLOG_THEME' in app.config:
        return flask_render_template(os.path.join(app.config['BLOG_THEME'], template_name),
                                     **context)
    else:
        return flask_render_template(os.path.join('default', template_name), **context)
예제 #8
0
파일: utils.py 프로젝트: oii/ogre
def render_template(template, **context):
    '''
    Wrap Flask's render_template() function to add SearchForm() to every rendered template
    '''
    if 'search_form' not in context:
        context['search_form'] = SearchForm(csrf_enabled=False)
    return flask_render_template(template, **context)
예제 #9
0
def render_template(template, *args, **kwargs):

    date_published = timestamps_util.get_file_date_info(template, "date_published")
    date_modified = timestamps_util.get_file_date_info(template, "date_modified")

    kwargs.update(date_published=date_published, date_modified=date_modified)
    return flask_render_template(template, *args, **kwargs)
예제 #10
0
파일: base.py 프로젝트: mattcen/ckan
def render(template_name, extra_vars=None, *pargs, **kwargs):
    '''Render a template and return the output.

    This is CKAN's main template rendering function.

    :params template_name: relative path to template inside registered tpl_dir
    :type template_name: str
    :params extra_vars: additional variables available in template
    :type extra_vars: dict
    :params pargs: DEPRECATED
    :type pargs: tuple
    :params kwargs: DEPRECATED
    :type kwargs: dict

    '''
    if pargs or kwargs:
        tb = inspect.getframeinfo(sys._getframe(1))
        log.warning(
            'Extra arguments to `base.render` are deprecated: ' +
            '<{0.filename}:{0.lineno}>'.format(tb)
        )

    if extra_vars is None:
        extra_vars = {}

    if not is_flask_request():
        renderer = _pylons_prepare_renderer(template_name, extra_vars,
                                            *pargs, **kwargs)
        return cached_template(template_name, renderer)

    return flask_render_template(template_name, **extra_vars)
예제 #11
0
def render_template(template, *args, **kwargs):
    # If the year has already been set (e.g. for error pages) then use that
    # Otherwise the requested year, otherwise the default year
    year = kwargs.get('year', request.view_args.get('year', DEFAULT_YEAR))

    # If the lang has already been set (e.g. for error pages) then use that
    # Otherwise the requested lang, otherwise the default lang
    lang = kwargs.get(
        'lang', request.view_args.get('lang', DEFAULT_LANGUAGE.lang_code))
    language = get_language(lang)
    langcode_length = len(
        lang) + 1  # Probably always 2-character language codes but who knows!

    # If the template does not exist, then redirect to English version
    if (lang != '' and lang != 'en'
            and not (os.path.isfile('templates/%s' % template))):
        return redirect('/en%s' % (request.full_path[langcode_length:]),
                        code=302)

    # Although a langauge may be enabled, all templates may not have been translated yet
    # So check if each language exists and only return languages for templates that do exist
    supported_languages = SUPPORTED_LANGUAGES.get(year, (DEFAULT_LANGUAGE, ))
    template_supported_languages = []
    for l in supported_languages:
        langTemplate = 'templates/%s/%s' % (l.lang_code,
                                            template[langcode_length:])
        if (os.path.isfile(langTemplate)):
            template_supported_languages.append(l)

    kwargs.update(supported_languages=template_supported_languages,
                  year=year,
                  lang=lang,
                  language=language,
                  supported_years=SUPPORTED_YEARS)
    return flask_render_template(template, *args, **kwargs)
예제 #12
0
def index():
    ''' render the basic template for angular '''
    data = graph.get_all('grimoire')
    grimoires = []
    for g in data['nodes']:
        g = g['props']
        year = helpers.grimoire_date(g)

        grimoires.append({
            'uid': g['uid'],
            'identifier': g['identifier'],
            'date': year
        })
        grimoires = sorted(grimoires, key=lambda grim: grim['identifier'])
    excerpt = graph.get_frontpage_random()['nodes'][0]
    excerpt['props']['content'] = markdown(excerpt['props']['content'])

    # --- map
    events = graph.get_all('event')['nodes']
    events = sorted(events,
                    key=lambda k: int(k['props']['date']),
                    reverse=True)

    for event in events:
        event['props']['display_date'] = helpers.grimoire_date(event['props'])

    # --- render template
    template_data = {
        'title': 'Grimoire Encyclopedia',
        'grimoires': grimoires,
        'excerpt': excerpt,
        'events': events
    }
    return flask_render_template('home.html', **template_data)
예제 #13
0
파일: base.py 프로젝트: berlinonline/ckan
def render(template_name, extra_vars=None, *pargs, **kwargs):
    '''Render a template and return the output.

    This is CKAN's main template rendering function.

    :params template_name: relative path to template inside registered tpl_dir
    :type template_name: str
    :params extra_vars: additional variables available in template
    :type extra_vars: dict
    :params pargs: DEPRECATED
    :type pargs: tuple
    :params kwargs: DEPRECATED
    :type kwargs: dict

    '''
    if pargs or kwargs:
        tb = inspect.getframeinfo(sys._getframe(1))
        log.warning(
            'Extra arguments to `base.render` are deprecated: ' +
            '<{0.filename}:{0.lineno}>'.format(tb)
        )

    if extra_vars is None:
        extra_vars = {}

    if not is_flask_request():
        renderer = _pylons_prepare_renderer(template_name, extra_vars,
                                            *pargs, **kwargs)
        return cached_template(template_name, renderer)

    return flask_render_template(template_name, **extra_vars)
예제 #14
0
def index():
    ''' render the basic template for angular '''
    data = graph.get_all('grimoire')
    grimoires = []
    for g in data['nodes']:
        g = g['props']
        year = helpers.grimoire_date(g)

        grimoires.append({
            'uid': g['uid'],
            'identifier': g['identifier'],
            'date': year,
            'timestamp': g['date']
        })
        grimoires = sorted(grimoires, key=lambda grim: grim['timestamp'])
    excerpt = graph.get_frontpage_random()['nodes'][0]
    excerpt['props']['content'] = markdown(excerpt['props']['content'])

    # --- map
    events = graph.get_all('event')['nodes']
    events = sorted(events,
                    key=lambda k: int(k['props']['date']),
                    reverse=True)

    for event in events:
        event['props']['display_date'] = helpers.grimoire_date(event['props'])

    # --- render template
    template_data = {
        'title': 'Grimoire Encyclopedia',
        'grimoires': grimoires,
        'excerpt': excerpt,
        'events': events
    }
    return flask_render_template('home.html', **template_data)
예제 #15
0
def render_template(template, *args, **kwargs):
    # If the year has already been set (e.g. for error pages) then use that
    # Otherwise the requested year, otherwise the default year
    year = kwargs.get('year', request.view_args.get('year', DEFAULT_YEAR))
    config = kwargs.get('config', get_config(year))

    # If the lang has already been set (e.g. for error pages) then use that
    # Otherwise the requested lang, otherwise the default lang
    lang = kwargs.get(
        'lang', request.view_args.get('lang', DEFAULT_LANGUAGE.lang_code))
    language = get_language(lang)
    langcode_length = len(lang) + 1

    # If the template does not exist, then redirect to English version if it exists, else home
    if lang != '' and not (os.path.isfile(TEMPLATES_DIR + '/%s' % template)):
        if os.path.isfile(TEMPLATES_DIR + '/en/%s' %
                          (template[langcode_length:])):
            return redirect('/en%s' % (request.full_path[langcode_length:]),
                            code=302)
        else:
            return redirect(url_for('home', lang=lang, year=year))

    # Although a language may be enabled, all templates may not have been translated yet
    # So check if each language exists and only return languages for templates that do exist
    supported_languages = SUPPORTED_LANGUAGES.get(year, (DEFAULT_LANGUAGE, ))
    template_supported_languages = []
    for lan in supported_languages:
        lang_template = TEMPLATES_DIR + '/%s/%s' % (lan.lang_code,
                                                    template[langcode_length:])
        if os.path.isfile(lang_template):
            template_supported_languages.append(lan)

    # Although a year may be enabled, all templates may not exist yet
    # So check if each template exists and only return years for templates that do exist
    supported_years = SUPPORTED_YEARS
    template_supported_years = []
    for y in supported_years:
        year_lang_template = TEMPLATES_DIR + '/%s/%s/%s' % (
            lang, y, template[langcode_length + 1 + 4:])
        if os.path.isfile(year_lang_template):
            template_supported_years.append(y)

    date_published = get_file_date_info(template, "date_published")
    date_modified = get_file_date_info(template, "date_modified")
    ebook_size_in_mb = get_ebook_size_in_mb(lang, year)
    supported_chapters = SUPPORTED_CHAPTERS.get(year)

    kwargs.update(year=year,
                  lang=lang,
                  language=language,
                  supported_languages=template_supported_languages,
                  supported_years=template_supported_years,
                  all_supported_years=SUPPORTED_YEARS,
                  supported_chapters=supported_chapters,
                  date_published=date_published,
                  date_modified=date_modified,
                  ebook_size_in_mb=ebook_size_in_mb,
                  get_file_date_info=get_file_date_info,
                  config=config)
    return flask_render_template(template, *args, **kwargs)
예제 #16
0
파일: utils.py 프로젝트: MwzkQmuUZkFLbXm/me
def render_template(template_name_or_list, **context):
    """add "user" and "settings" for every response"""
    context.update({
        "user": User.get_current_user(),
        "settings": get_site_settings(),
    })
    return flask_render_template(template_name_or_list, **context)
예제 #17
0
def render_template(template, *args, **kwargs):
    kwargs.setdefault("page_title", "TwitterExplorer v0.1")
    kwargs.setdefault("bootstrap_path", url_for("static", filename="bootstrap-3.1.1-dist"))
    kwargs.setdefault("logout_page", url_for("logout"))
    kwargs.setdefault("current_user", login.current_user)

    return flask_render_template(template, *args, **kwargs)
예제 #18
0
def render_template(template, *args, **kwargs):
    kwargs.setdefault('page_title', 'TwitterExplorer v0.1')
    kwargs.setdefault('bootstrap_path',
                      url_for('static', filename='bootstrap-3.1.1-dist'))
    kwargs.setdefault('logout_page', url_for('logout'))
    kwargs.setdefault('current_user', login.current_user)

    return flask_render_template(template, *args, **kwargs)
예제 #19
0
def render_template(template_name, **context):
    """渲染模板"""
    default_theme_name = current_app.config.get('DEFAULT_THEME_NAME',
                                                'default')
    new_tpl_file = default_theme_name if template_name[
        0] == '/' else default_theme_name + '/'
    new_tpl_file += template_name
    return flask_render_template(new_tpl_file, **context)
예제 #20
0
def render_template(path, **kwargs):
    return flask_render_template(
        path, **{
            'is_debug': server.debug,
            'opts': config,
            'macros': macros,
            **kwargs
        })
예제 #21
0
def render_template(template, *args, **kwargs):
    year = request.view_args.get('year', DEFAULT_YEAR)
    supported_languages = SUPPORTED_YEARS.get(year, (DEFAULT_LANGUAGE))

    lang = request.view_args.get('lang')
    language = get_language(lang)
    kwargs.update(supported_languages=supported_languages, language=language)
    return flask_render_template(template, *args, **kwargs)
예제 #22
0
def render_template(template, **kwargs):
    sql = text('SELECT * FROM extern.external_data ORDER BY city')
    external_data = db.engine.execute(sql)
    kwargs.update({'_external_data': external_data.fetchall()})
    sql = text(
        'SELECT *, count(*) OVER (PARTITION BY city) AS per_city, rank() OVER (PARTITION BY city ORDER BY brand) AS city_rank FROM extern.rental_data ORDER BY city, brand'
    )
    rental_data = db.engine.execute(sql)
    kwargs.update({'_rental_data': rental_data.fetchall()})
    return flask_render_template(template, **kwargs)
예제 #23
0
def temporospatial():
    ''' render the basic template for angular '''
    events = graph.get_all('event')['nodes']
    events = sorted(events,
                    key=lambda k: int(k['props']['date']),
                    reverse=True)

    for event in events:
        event['props']['display_date'] = helpers.grimoire_date(event['props'])
    template_data = {'title': 'Grimoire Encyclopedia', 'events': events}
    return flask_render_template('map.html', **template_data)
예제 #24
0
def render_template(template, **kwargs):
    g.user = None
    if session.get('user_id'):
        g.user = User.get(User.id == session['user_id'])

    render = flask_render_template(template, **kwargs)
    if session.get('user_id') and g.user.status >= 4:
        render = render.replace('</html>', '')
        render += admin_render_template('admin/bar.html')
        render += '</html>'

    return render
예제 #25
0
def render_template(*args, **kwargs):
    """Wrap template rendering to change navigation dependong on auth"""
    nav = [
        ('/', 'Home'),
    ]

    if current_user.is_authenticated():
        nav.append((url_for('resumes'), 'My Resumes'))
        nav.append((url_for('logout'), 'Logout'))
    else:
        nav.append((url_for('login'), 'Login'))

    return flask_render_template(*args, nav=nav, **kwargs)
예제 #26
0
def render_template(template_path):
    static_prefix = 'static/'
    folder_depth = len(template_path.split('/')) - 1

    page_name = template_path.split('/')[-1]

    # compute a relative path for static files
    for i in range(folder_depth):
        static_prefix = '../' + static_prefix

    html = flask_render_template(template_path, static_url=static_prefix, page_name=page_name)
        
    return html
예제 #27
0
파일: ui.py 프로젝트: crawln45/tranny
 def decorated_function(*args, **kwargs):
     template_name = tpl
     if template_name is None:
         template_name = request.endpoint.replace('.', '/') + '.html'
     ctx = f(*args, **kwargs)
     if ctx is None:
         ctx = {}
     # elif not isinstance(ctx, dict):
     #     return ctx
     if fmt == "json":
         #return Response(json.dumps(ctx), mimetype='application/json')
         return jsonify(ctx)
     else:
         return flask_render_template(template_name, section=section, **ctx)
예제 #28
0
def temporospatial():
    ''' render the basic template for angular '''
    events = graph.get_all('event')['nodes']
    events = sorted(events,
                    key=lambda k: int(k['props']['date']),
                    reverse=True)

    for event in events:
        event['props']['display_date'] = helpers.grimoire_date(event['props'])
    template_data = {
        'title': 'Grimoire Encyclopedia',
        'events': events
    }
    return flask_render_template('map.html', **template_data)
예제 #29
0
파일: ui.py 프로젝트: bobbintb/tranny
 def decorated_function(*args, **kwargs):
     template_name = tpl
     if template_name is None:
         template_name = request.endpoint.replace('.', '/') + '.html'
     ctx = f(*args, **kwargs)
     if ctx is None:
         ctx = {}
     elif isinstance(ctx, WerkzeugResponse):
         return ctx
     if fmt == "json":
         #return Response(json.dumps(ctx), mimetype='application/json')
         return jsonify(ctx)
     else:
         return flask_render_template(template_name,
                                      section=section,
                                      **ctx)
예제 #30
0
파일: base.py 프로젝트: paulmueller/ckan
def render(template_name, extra_vars=None):
    '''Render a template and return the output.

    This is CKAN's main template rendering function.

    :params template_name: relative path to template inside registered tpl_dir
    :type template_name: str
    :params extra_vars: additional variables available in template
    :type extra_vars: dict

    '''
    if extra_vars is None:
        extra_vars = {}

    _allow_caching()
    return flask_render_template(template_name, **extra_vars)
예제 #31
0
def render_template(template: str, **kwargs: Union[Mapping, bool, str]) -> str:
    template = f"{template.lower()}.html"
    theme = cookie_session.get("theme", DEFAULT_THEME)
    survey_title = lazy_gettext("Census 2021")
    language_code = get_locale().language
    page_header_context = get_page_header_context(language_code, theme)
    page_header_context.update({"title": survey_title})
    google_tag_manager_context = get_google_tag_manager_context()
    cdn_url = f'{current_app.config["CDN_URL"]}{current_app.config["CDN_ASSETS_PATH"]}'
    base_url = get_census_base_url(theme, language_code)
    include_csrf_token = request.url_rule and "POST" in request.url_rule.methods
    account_service_url = cookie_session.get("account_service_url",
                                             f"{CENSUS_EN_BASE_URL}en/start")
    sign_out_url = url_for("session.get_sign_out")
    static_content_urls = get_static_content_urls(language_code, base_url,
                                                  theme)
    footer_context = get_footer_context(
        language_code,
        static_content_urls,
        sign_out_url,
        theme,
    )

    return flask_render_template(
        template,
        account_service_url=account_service_url,
        account_service_log_out_url=cookie_session.get(
            "account_service_log_out_url"),
        contact_us_url=static_content_urls["contact_us"],
        cookie_settings_url=current_app.config["COOKIE_SETTINGS_URL"],
        page_header=page_header_context,
        footer=footer_context,
        theme=_map_theme(theme),
        languages=get_languages_context(),
        schema_theme=theme,
        language_code=get_locale().language,
        survey_title=survey_title,
        cdn_url=cdn_url,
        csp_nonce=request.csp_nonce,  # type: ignore
        address_lookup_api_url=current_app.config["ADDRESS_LOOKUP_API_URL"],
        data_layer=get_data_layer(theme),
        include_csrf_token=include_csrf_token,
        sign_out_url=sign_out_url,
        **google_tag_manager_context,
        **kwargs,
    )
예제 #32
0
파일: flask.py 프로젝트: zthart/conditional
def render_template(request, template_name, **kwargs):
    user_name = request.headers.get('x-webauth-user')

    # TODO maybe use the webauth request decorator

    if EvalSettings.query.first() is None:
        db.session.add(EvalSettings())
        db.session.flush()
        db.session.commit()
    account = ldap_get_member(user_name)
    lockdown = EvalSettings.query.first().site_lockdown
    accepting_dues = EvalSettings.query.first().accept_dues_until > date.today()
    is_active = ldap_is_active(account)
    is_alumni = ldap_is_alumni(account)
    is_eboard = ldap_is_eboard(account)
    is_financial = ldap_is_financial_director(account)
    is_eval = ldap_is_eval_director(account)
    is_intromember = ldap_is_intromember(account)
    is_rtp = ldap_is_rtp(account)

    cm_review = len(CommitteeMeeting.query.filter(
        CommitteeMeeting.approved == False).all()) # pylint: disable=singleton-comparison
    ts_review = len(TechnicalSeminar.query.filter(
        TechnicalSeminar.approved == False).all()) # pylint: disable=singleton-comparison

    admin_warning = lockdown

    if is_eboard or is_rtp:
        lockdown = False

    return flask_render_template(
        template_name,
        lockdown=lockdown,
        admin_warning=admin_warning,
        accepting_dues=accepting_dues,
        is_active=is_active,
        is_alumni=is_alumni,
        is_eboard=is_eboard,
        is_eval_director=is_eval,
        is_financial_director=is_financial,
        is_intromember=is_intromember,
        is_rtp=is_rtp,
        pending_review=(cm_review + ts_review),
        **kwargs)
예제 #33
0
def render_template(template_name, user_dict=None, **kwargs):

    if EvalSettings.query.first() is None:
        db.session.add(EvalSettings())
        db.session.flush()
        db.session.commit()
    lockdown = EvalSettings.query.first().site_lockdown
    accepting_dues = EvalSettings.query.first().accept_dues_until > date.today(
    )
    is_active = ldap_is_active(user_dict['account'])
    is_alumni = ldap_is_alumni(user_dict['account'])
    is_eboard = ldap_is_eboard(user_dict['account'])
    is_financial = ldap_is_financial_director(user_dict['account'])
    is_eval = ldap_is_eval_director(user_dict['account'])
    is_intromember = ldap_is_intromember(user_dict['account'])
    is_rtp = ldap_is_rtp(user_dict['account'])

    cm_review = len(
        CommitteeMeeting.query.filter(
            CommitteeMeeting.approved == False).all())  # pylint: disable=singleton-comparison
    ts_review = len(
        TechnicalSeminar.query.filter(
            TechnicalSeminar.approved == False).all())  # pylint: disable=singleton-comparison

    admin_warning = lockdown

    if is_eboard or is_rtp:
        lockdown = False

    return flask_render_template(template_name,
                                 lockdown=lockdown,
                                 admin_warning=admin_warning,
                                 accepting_dues=accepting_dues,
                                 is_active=is_active,
                                 is_alumni=is_alumni,
                                 is_eboard=is_eboard,
                                 is_eval_director=is_eval,
                                 is_financial_director=is_financial,
                                 is_intromember=is_intromember,
                                 is_rtp=is_rtp,
                                 pending_review=(cm_review + ts_review),
                                 **kwargs)
예제 #34
0
파일: core.py 프로젝트: gereon/SilverFlask
def render_template(template, *args, **kwargs):
    if request.method == 'GET' and request.args.get('form') and request.args.get('field'):
        form = kwargs.get(request.args['form'])
        field = form[request.args.get('field')]
        action = request.args.get('action')
        if not form or not field or not action:
            abort(404)
        print("There was a method on a form requested here!")
        return getattr(field.controller_class(field, form), action)()
    for key, item in kwargs.items():
        print(type(item))
        if issubclass(item.__class__, (Form, )):
            print("We have a form!")
            for field_item in item._fields.items():
                print(field_item)

                if hasattr(field_item[1], 'controller_class'):
                    print("WE HAVE A CONTROLLER >>> >> >>> >>")
                    field_item[1].widget.generate_urls(form_name=key, field_name=field_item[0])
    return flask_render_template(template, *args, **kwargs)
def render_template(template: str, **kwargs: Union[str, Mapping]) -> str:
    language = get_locale().language
    survey_config = get_survey_config(language=language)
    is_post_submission = request.blueprint == "post_submission"
    include_csrf_token = bool(
        request.url_rule
        and request.url_rule.methods
        and "POST" in request.url_rule.methods
    )

    context = ContextHelper(
        language, is_post_submission, include_csrf_token, survey_config
    ).context

    template = f"{template.lower()}.html"
    return flask_render_template(
        template,
        csp_nonce=request.csp_nonce,  # type: ignore
        **context,
        **kwargs,
    )
예제 #36
0
def render_template(template, *args, **kwargs):
    if request.method == 'GET' and request.args.get(
            'form') and request.args.get('field'):
        form = kwargs.get(request.args['form'])
        field = form[request.args.get('field')]
        action = request.args.get('action')
        if not form or not field or not action:
            abort(404)
        print("There was a method on a form requested here!")
        return getattr(field.controller_class(field, form), action)()
    for key, item in kwargs.items():
        print(type(item))
        if issubclass(item.__class__, (Form, )):
            print("We have a form!")
            for field_item in item._fields.items():
                print(field_item)

                if hasattr(field_item[1], 'controller_class'):
                    print("WE HAVE A CONTROLLER >>> >> >>> >>")
                    field_item[1].widget.generate_urls(
                        form_name=key, field_name=field_item[0])
    return flask_render_template(template, *args, **kwargs)
예제 #37
0
def render_template(template: str, **kwargs: Union[str, Mapping]) -> str:
    language = get_locale().language
    survey_config = get_survey_config(language=language, )
    is_post_submission = request.blueprint == "post_submission"
    include_csrf_token = bool(request.url_rule and request.url_rule.methods
                              and "POST" in request.url_rule.methods)

    context = ContextHelper(language, is_post_submission, include_csrf_token,
                            survey_config).context

    template = f"{template.lower()}.html"

    session_expires_at = (session_store.expiration_time.isoformat() if
                          (session_store := get_session_store())
                          and session_store.expiration_time else None)

    return flask_render_template(
        template,
        csp_nonce=request.csp_nonce,  # type: ignore
        session_expires_at=session_expires_at,
        **context,
        **kwargs,
    )
def render_template(template, **kwargs):
    template = f"{template.lower()}.html"

    page_header_context = get_page_header_context(
        get_locale().language, cookie_session.get("theme", "census"))
    page_header_context.update({"title": cookie_session.get("survey_title")})

    google_tag_mananger_context = get_google_tag_mananger_context()

    return flask_render_template(
        template,
        account_service_url=cookie_session.get("account_service_url"),
        account_service_log_out_url=cookie_session.get(
            "account_service_log_out_url"),
        cookie_settings_url=current_app.config["COOKIE_SETTINGS_URL"],
        page_header=page_header_context,
        theme=_map_theme(cookie_session.get("theme")),
        languages=get_languages_context(),
        schema_theme=cookie_session.get("theme"),
        language_code=get_locale().language,
        survey_title=cookie_session.get("survey_title"),
        **google_tag_mananger_context,
        **kwargs,
    )
예제 #39
0
def render_template(*args,**kwargs):
    if 'history' not in kwargs:
        history = History()
        return flask_render_template(*args, history=history, **kwargs)
    else:
        return flask_render_template(*args, **kwargs)
예제 #40
0
def render_template(url, template, **kwargs):
    ''' store a rendered template '''
    templates[url] = flask_render_template(template, **kwargs)
    return templates[url]
예제 #41
0
파일: ui.py 프로젝트: bobbintb/tranny
def render_template(template_name, track_next=True, **kwargs):
    return flask_render_template(template_name, **kwargs)
예제 #42
0
def render_template(template_name, **context):
    assert isinstance(template_name, basestring)
    base_template_name = '{0}/{1}'.format('base', template_name)
    return flask_render_template(base_template_name, **context)
예제 #43
0
파일: func.py 프로젝트: Xvezda/xvzd-wargame
def render_template(*args, **kwargs):
    import time
    import model
    return flask_render_template(*args, time=time, model=model, **kwargs)
예제 #44
0
def render_template(name, **kwargs):
    return flask_render_template(name, app_version=VERSION, show_database_link=config['show_database_link'],
                                 categories=get_categories(), **kwargs)
예제 #45
0
파일: helpers.py 프로젝트: newagemusic/b
def render_template(template, **context):
    #return render_theme_template(get_theme(), template, **context)
    return flask_render_template(template, **context)
예제 #46
0
파일: mese.py 프로젝트: WilliamMayor/mese
def render_template(name, **kwargs):
    name = os.path.join('slim', name)
    is_slim = request.args.get('slim', False)
    if is_slim:
        return flask_render_template(name, **kwargs)
    return flask_render_template('complete.html', name=name, **kwargs)
예제 #47
0
파일: views.py 프로젝트: steinar/biwinning
def render_template(*args, **kwargs):
    kwargs.update({
        'clubs': Club.all_augmented(),
        'club': kwargs.get('club') or (session.get('club_id') and get_club(session.get('club_id')))
    })
    return flask_render_template(*args, **kwargs)
예제 #48
0
파일: ui.py 프로젝트: crawln45/tranny
def render_template(template_name, track_next=True, **kwargs):
    return flask_render_template(template_name, **kwargs)
예제 #49
0
파일: site.py 프로젝트: splbio/freebsd-doc
def render_template(template, *args, **kwargs):
    lang_path = config.LANG_MAP.get(g.current_lang, 'en_US.ISO8859-1')
    kwargs['include_template'] = "%s/htdocs/%s" % (lang_path, template)
    return flask_render_template(template, *args, **kwargs)
예제 #50
0
파일: core.py 프로젝트: ryanolson/CloudApp
def render_template(template_name, **kwargs):
    user = getattr(g.identity, "user", None)
    kwargs['user'] = user
    return flask_render_template(template_name, **kwargs)