def theme(): from flask.ext.themes import get_themes_list l = get_themes_list() n = ' ' print l[1].name for a in l: n.join(a.name) return l[1].name
def website_edit(website): g.website = website form = WebsiteForm(obj=website) themes = [(t.identifier, t.name) for t in get_themes_list()] form.theme.choices = themes if form.validate_on_submit(): form.populate_obj(website) db.session.commit() return render_redirect(url_for('website', website=website.name), code=303) return render_form(form=form, title=u"Edit website", submit=u"Save", cancel_url=url_for('website', website=website.name), ajax=True)
def website_new(): form = WebsiteForm() themes = [(t.identifier, t.name) for t in get_themes_list()] form.theme.choices = themes if form.validate_on_submit(): website = Website() form.populate_obj(website) db.session.add(website) db.session.commit() return render_redirect(url_for("website", website=website.name), code=303) return render_form(form=form, title=u"New website", submit=u"Create", cancel_url=url_for("index"), ajax=True)
def folder_new(website): g.website = website form = FolderForm() themes = [('', 'Website Default')] + [(t.identifier, t.name) for t in get_themes_list()] form.theme.choices = themes if form.validate_on_submit(): folder = Folder(website=website) form.populate_obj(folder) db.session.add(folder) db.session.commit() return render_redirect(url_for('folder', website=website.name, folder=folder.name), code=303) return render_form(form=form, title=u"New folder", submit=u"Create", cancel_url=url_for('website', website=website.name), ajax=True)
def folder_edit(website, folder): g.website = website g.folder = folder form = FolderForm(obj=folder) if request.method == 'GET': form.theme.data = folder._theme themes = [('', 'Website Default')] + [(t.identifier, t.name) for t in get_themes_list()] form.theme.choices = themes if form.validate_on_submit(): form.populate_obj(folder) db.session.commit() return render_redirect(url_for('folder', website=website.name, folder=folder.name), code=303) return render_form(form=form, title=u"Edit folder", submit=u"Save", cancel_url=url_for('folder', website=website.name, folder=folder.name), ajax=True)
def website_new(): form = WebsiteForm() themes = [(t.identifier, t.name) for t in get_themes_list()] form.theme.choices = themes if form.validate_on_submit(): website = Website() form.populate_obj(website) db.session.add(website) db.session.commit() return render_redirect(url_for('website', website=website.name), code=303) return render_form(form=form, title=u"New website", submit=u"Create", cancel_url=url_for('index'), ajax=True)
def test_get_helpers(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] setup_themes(app, app_identifier='testing') with app.test_request_context('/'): cool = app.theme_manager.themes['cool'] plain = app.theme_manager.themes['plain'] assert get_theme('cool') is cool assert get_theme('plain') is plain tl = get_themes_list() assert tl[0] is cool assert tl[1] is plain try: get_theme('notthis') except KeyError: pass else: raise AssertionError("Getting a nonexistent theme should " "raised KeyError")
assert hasattr(app, 'theme_manager') assert '_themes' in app.blueprints assert 'theme' in app.jinja_env.globals assert 'theme_static' in app.jinja_env.globals def test_get_helpers(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] setup_themes(app, app_identifier='testing') with app.test_request_context('/'): cool = app.theme_manager.themes['cool'] plain = app.theme_manager.themes['plain'] assert get_theme('cool') is cool assert get_theme('plain') is plain tl = get_themes_list() assert tl[0] is cool assert tl[1] is plain try: get_theme('notthis') except KeyError: pass else: raise AssertionError("Getting a nonexistent theme should " "raised KeyError") class TestStatic(object): def test_static_file_url(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
def themes(): themes = get_themes_list() return render('themes.html', themes=themes)