示例#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
示例#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
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
    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")
示例#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)
示例#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")
示例#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)
示例#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')]
示例#14
0
def themes():
    themes = get_themes_list()
    return render('themes.html', themes=themes)