Example #1
0
def edit_siteconfig():
    # In the current configuration there is only one SiteConfig
    # This would change if more "Sites" are configured through one CMS
    siteconfig = db.session.query(SiteConfig).first()
    if not siteconfig:
        siteconfig = SiteConfig()
        db.session.add(siteconfig)
        db.session.commit()
    form = siteconfig.get_cms_form()
    form = form(request.form, obj=siteconfig)
    if form.validate_on_submit():
        form.populate_obj(siteconfig)
        db.session.commit()
    return render_template("data_object/edit.html", form=form)
Example #2
0
def edit_siteconfig():
    # In the current configuration there is only one SiteConfig
    # This would change if more "Sites" are configured through one CMS
    siteconfig = db.session.query(SiteConfig).first()
    if not siteconfig:
        siteconfig = SiteConfig()
        db.session.add(siteconfig)
        db.session.commit()

    form = siteconfig.get_cms_form()
    # form.fields['theme'].choices = get_available_themes()
    form = form(request.form, obj=siteconfig)
    if form.validate_on_submit():
        form.populate_obj(siteconfig)
        db.session.commit()
    return render_template("data_object/edit.html", form=form)
Example #3
0
def createdb():
    """
    Creates a database with the defined models
    and also adds the default records that are needed for the CMS:
    Admin User, Admin Role, Default first page, and stuff
    """

    db.create_all()
    from silverflask.models import User
    from silverflask.models.User import Role
    if not len(Role.query.all()):
        admin_role = Role("admin", "Admin has all privileges")
        db.session.add(admin_role)
        db.session.commit()

    if not len(User.query.all()):
        # create standard user
        u = User("admin", "admin")
        u.firstname = "Default"
        u.lastname = "Admin"
        u.email = "admin"
        db.session.add(u)
        admin_role = Role.query.filter(Role.name == "admin").first()
        u.roles.append(admin_role)
        db.session.commit()

    from silverflask.models import SiteConfig
    if not len(SiteConfig.query.all()):
        sc = SiteConfig()
        sc.title = "Your SilverFlask Website"
        sc.tagline = "This is a default installation"
        db.session.add(sc)
        db.session.commit()

    if not len(Page.query.all()):
        page = Page()
        page.content = "<p>Please proceed to the admin interface at <a href='/admin'>admin</a>!</p>"
        page.name = "home"
        page.urlsegment = "home"
        db.session.add(page)
        db.session.commit()
        page.mark_as_published()
        db.session.commit()
Example #4
0
    def setUp(self):
        """
        Initialize app and setup admin user ('admin', 'admin'), a SiteConfig and
        a Page.
        """
        self.create_app()
        from silverflask.models import User
        from silverflask.models.User import Role
        if not len(Role.query.all()):
            admin_role = Role("admin", "Admin has all privileges")
            db.session.add(admin_role)
            db.session.commit()

        if not len(User.query.all()):
            # create standard user
            u = User("admin", "admin")
            u.email = "admin"
            db.session.add(u)
            admin_role = Role.query.filter(Role.name == "admin").first()
            u.roles.append(admin_role)
            db.session.commit()

        from silverflask.models import SiteConfig
        if not len(SiteConfig.query.all()):
            sc = SiteConfig()
            db.session.add(sc)
            db.session.commit()

        if not len(Page.query.all()):
            page = Page()
            page.content = "<p>Please proceed to the admin interface at <a href='/admin'>admin</a>!</p>"
            page.name = "home"
            page.urlsegment = "home"
            db.session.add(page)
            db.session.commit()
            page.mark_as_published()
            db.session.commit()
Example #5
0
 def current_theme(self):
     theme = current_app.silverflask_theme_manager[SiteConfig.get_current().theme]
     if not theme:
         theme = current_app.silverflask_theme_manager['simple']
     return theme
Example #6
0
 def current_theme(self):
     theme = current_app.silverflask_theme_manager[
         SiteConfig.get_current().theme]
     if not theme:
         theme = current_app.silverflask_theme_manager['simple']
     return theme