def test_render_theme_template(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] Themes(app, app_identifier='testing') with app.test_request_context('/'): coolsrc = render_theme_template('cool', 'hello.html').strip() plainsrc = render_theme_template('plain', 'hello.html').strip() assert coolsrc == 'Hello from Cool Blue v2.' assert plainsrc == 'Hello from the application'
def test_active_theme(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] Themes(app, app_identifier='testing') with app.test_request_context('/'): appdata = render_template('active.html').strip() cooldata = render_theme_template('cool', 'active.html').strip() plaindata = render_theme_template('plain', 'active.html').strip() assert appdata == 'Application, Active theme: none' assert cooldata == 'Cool Blue v2, Active theme: cool' assert plaindata == 'Application, Active theme: plain'
def information(message_identifier): front_end_message = get_messages(message_identifier) if front_end_message: logger.debug(front_end_message) return render_theme_template('default', 'information.html', messages=front_end_message) raise NotFound
def page_not_found(e): """ Renders 404 Error page """ context = {} return (render_theme_template(get_current_theme(), '404.html', **context), 404)
def render(template, **context): ''' Render a template with uData frontend specifics * Theme ''' theme = current_app.config['THEME'] return render_theme_template(get_theme(theme), template, **context)
def _render_error_page(status_code): tx_id = None metadata = get_metadata(current_user) if metadata: tx_id = convert_tx_id(metadata["tx_id"]) user_agent = user_agent_parser.Parse(request.headers.get('User-Agent', '')) return render_theme_template('default', 'errors/error.html', status_code=status_code, ua=user_agent, tx_id=tx_id), status_code
def _render_error_page(status_code): tx_id = get_tx_id() user_agent = user_agent_parser.Parse(request.headers.get('User-Agent', '')) return render_theme_template('default', 'errors/error.html', status_code=status_code, analytics_ua_id=settings.EQ_UA_ID, ua=user_agent, tx_id=tx_id), status_code
def test_theme_static(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] Themes(app, app_identifier='testing') with app.test_request_context('/'): coolurl = static_file_url('cool', 'style.css') cooldata = render_theme_template('cool', 'static.html').strip() assert cooldata == 'Cool Blue v2, %s' % coolurl
def render_template(template, **context): """A helper function that uses the `render_theme_template` function without needing to edit all the views """ if current_user.is_authenticated() and current_user.theme: theme = current_user.theme else: theme = session.get('theme', current_app.config['DEFAULT_THEME']) return render_theme_template(theme, template, **context)
def render_template(template, **context): """A helper function that uses the `render_theme_template` function without needing to edit all the views """ if current_user.is_authenticated() and current_user.theme: theme = current_user.theme else: theme = session.get('theme', flaskbb_config['DEFAULT_THEME']) return render_theme_template(theme, template, **context)
def main_live(id): race = races.find_one({'_id': ObjectId(id) }) theme = request.args.get('theme', race['theme']) try: t = get_theme(theme) except KeyError: flash(u"Thème introuvable: %s" % theme, "error") theme = "default" return render_theme_template(theme, "index.html", race_id=str(id), home_timeline=[])
def show_directory(): """ Renders a list of shows """ # Assuming you have an API that can return content based on a specific # key, this would be a potential usage. This way, you can filter # content specific from your API based on sites or other logical # groupings context = {'shows': get_shows(site_id=get_current_theme())} return (render_theme_template(get_current_theme(), "shows.html", **context))
def show_directory(): """ Renders a list of shows """ # Assuming you have an API that can return content based on a specific # key, this would be a potential usage. This way, you can filter # content specific from your API based on sites or other logical # groupings context = { 'shows': get_shows(site_id=get_current_theme()) } return (render_theme_template(get_current_theme(), "shows.html", **context))
def render(self): ctx = { 'page': self, 'entities': Entity.query.order_by('position').all(), 'timeline': Timeline.query.order_by(desc('date')).all(), 'main_menu': MenuItem.query.filter_by(parent=None).order_by('position').all() or Page.query.order_by('position').all(), 'references': [] } theme = Setting.query.filter_by(name=u'theme').first().value # Make reference list [re.sub(cite_pattern, convert_references(ctx['references']), sec.html) for sec in self.sections] rendered = render_theme_template(theme, 'pages/'+self.template, **ctx) rendered = re.sub(cite_pattern, convert_references(ctx['references']), rendered) return rendered
def live_default(): theme = request.args.get('theme', 'default') try: home_timeline = TW_Client.api.home_timeline() except TweepError: flash("Twitter: authentification impossible", "error") home_timeline = {} races_list = [{'_id': 'twitter', 'visible': 1, 'stared': 0 }] tw_list = [] for tw in home_timeline: tweet = Tweet(tw) tw_dict = marshal(tweet.__dict__, msg_race_flat) # classe... tw_dict['visible'] = 1 tw_dict['stared'] = 0 tw_dict['status'] = "" tw_list.append(tw_dict) return render_theme_template(theme, "index.html", race_id='twitter', home_timeline=json_dump(tw_list))
def render(template, **context): return render_theme_template(get_current_theme(app, g), template, **context)
def render_admin(template, **context): return render_theme_template(get_theme('admin'), template, **context)
def index(): """ This is the index """ context = {} return render_theme_template(get_current_theme(), "index.html", **context)
def unauthorized(error=None): log_exception(error, 401) return render_theme_template('default', 'session-expired.html'), 401
def render(template, **context): theme = session.get('theme', app.config['DEFAULT_THEME']) return render_theme_template(theme, template, **context)
def render_themed(template, **context): ident = current_app.config.get('DEFAULT_THEME', 'plain') return render_theme_template(get_theme(ident), template, **context)
def multiple_survey_error(error=None): log_exception(error) return render_theme_template('default', 'multiple_survey.html')
def render(template, **context): return render_theme_template(get_theme(), template, **context)
def render_template(template, **context): user = flask_login.current_user if not hasattr(user, 'skin_used') or user.skin_used == '': user.skin_used = 'default' return render_theme_template(user.skin_used, template, **context)
def render_template(template, **context): """""" context['site'] = get_current_request_site_info() context['user'] = _user_info() return render_theme_template(context['site']['settings']['theme'], template, **context)
def render_template(template, **context): return render_theme_template(get_default_theme(), template, **context)
def render_template(template, **context): """A helper function that uses the `render_theme_template` function without needing to edit all the views """ return render_theme_template('bootstrap3', template, **context)