Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
    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")
Exemplo n.º 10
0
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)
Exemplo n.º 11
0
    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")
Exemplo n.º 12
0
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)
Exemplo n.º 13
0
        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')]
Exemplo n.º 14
0
def themes():
    themes = get_themes_list()
    return render('themes.html', themes=themes)