Exemple #1
0
    def settings(self):
        form_settings = FormSettings()
        if form_settings.validate_on_submit():
            logo_alt = Setting.query.filter_by(name='logo_alt').first()
            logo_alt.value = form_settings.logo_alt.data
            if form_settings.logo_image.data:
                # If the user uploads an image from the form
                filename = secure_filename(form_settings.logo_image.data.filename)
                filepath = os.path.join(app.config['STATIC_IMAGES'], filename)
                form_settings.logo_image.data.save(filepath)
                logo_image = Setting.query.filter_by(name='logo_image').first()
                logo_image.value = filename
            if form_settings.favicon.data:
                # If the user uploads an image from the form
                filename = secure_filename(form_settings.favicon.data.filename)
                filepath = os.path.join(app.config['STATIC_IMAGES'], filename)
                form_settings.favicon.data.save(filepath)
                favicon = Setting.query.filter_by(name='favicon').first()
                favicon.value = filename
            title = Setting.query.filter_by(name='title').first()
            title.value = form_settings.title.data
            tagline = Setting.query.filter_by(name='tagline').first()
            tagline.value = form_settings.tagline.data
            title_html = Setting.query.filter_by(name='title_html').first()
            title_html.value = form_settings.title_html.data
            footer = Setting.query.filter_by(name='footer').first()
            footer.value = form_settings.footer.data
            credits = Setting.query.filter_by(name='credits').first()
            credits.value = form_settings.credits.data
            theme = Setting.query.filter_by(name='theme').first()
            theme.value = form_settings.theme.data
            keywords = Setting.query.filter_by(name='keywords').first()
            keywords.value = form_settings.keywords.data
            twitter_username = Setting.query.filter_by(name='twitter_username').first()
            twitter_username = form_settings.twitter_username.data
            db.session.commit()
            # Reload the settings
            load_settings()
            # Clear cache for homepage
            if redis_client:
                delete_redis_cache_keys('post_list')

        return redirect(url_for('admin.index'))
Exemple #2
0
    def settings(self):
        form_settings = FormSettings()
        if form_settings.validate_on_submit():
            logo_alt = Setting.query.filter_by(name='logo_alt').first()
            logo_alt.value = form_settings.logo_alt.data
            if form_settings.logo_image.data:
                # If the user uploads an image from the form
                filename = secure_filename(form_settings.logo_image.data.filename)
                filepath = os.path.join(app.config['STATIC_IMAGES'], filename)
                form_settings.logo_image.data.save(filepath)
                logo_image = Setting.query.filter_by(name='logo_image').first()
                logo_image.value = filename
            if form_settings.favicon.data:
                # If the user uploads an image from the form
                filename = secure_filename(form_settings.favicon.data.filename)
                filepath = os.path.join(app.config['STATIC_IMAGES'], filename)
                form_settings.favicon.data.save(filepath)
                favicon = Setting.query.filter_by(name='favicon').first()
                favicon.value = filename
            title = Setting.query.filter_by(name='title').first()
            title.value = form_settings.title.data
            tagline = Setting.query.filter_by(name='tagline').first()
            tagline.value = form_settings.tagline.data
            title_html = Setting.query.filter_by(name='title_html').first()
            title_html.value = form_settings.title_html.data
            footer = Setting.query.filter_by(name='footer').first()
            footer.value = form_settings.footer.data
            credits = Setting.query.filter_by(name='credits').first()
            credits.value = form_settings.credits.data
            theme = Setting.query.filter_by(name='theme').first()
            theme.value = form_settings.theme.data
            keywords = Setting.query.filter_by(name='keywords').first()
            keywords.value = form_settings.keywords.data
            twitter_username = Setting.query.filter_by(name='twitter_username').first()
            twitter_username.value = form_settings.twitter_username.data
            db.session.commit()
            # Reload the settings
            load_settings()
            # Clear cache for homepage
            if redis_client:
                delete_redis_cache_keys('post_list')

        return redirect(url_for('admin.index'))
Exemple #3
0
from modules.notifications import notifications


bp_filemanager = Blueprint('bp_filemanager', __name__, static_folder='static/files')
app.register_blueprint(bp_filemanager)
app.register_blueprint(settings, url_prefix='/settings')
app.register_blueprint(posts)
app.register_blueprint(users, url_prefix='/u')
app.register_blueprint(comments, url_prefix='/comments')
app.register_blueprint(notifications, url_prefix='/notifications')

from modules.users.model import user_datastore
from application.helpers.settings import load_settings

try:
    load_settings()
except OperationalError:
    pass
except ProgrammingError:
    pass


@app.context_processor
def theme_static_processor():
    def url_for_theme_static(filename):
        return url_for('theme_static', filename=filename)
    return {'url_for_theme_static': url_for_theme_static}


@app.errorhandler(404)
def page_not_found(e):
Exemple #4
0
from modules.notifications import notifications


filemanager = Blueprint('filemanager', __name__, static_folder='static/files')
app.register_blueprint(filemanager)
app.register_blueprint(settings, url_prefix='/settings')
app.register_blueprint(posts)
app.register_blueprint(users, url_prefix='/u')
app.register_blueprint(comments, url_prefix='/comments')
app.register_blueprint(notifications, url_prefix='/notifications')

from modules.users.model import user_datastore
from application.helpers.settings import load_settings

try:
    load_settings()
except OperationalError:
    pass
except ProgrammingError:
    pass

@app.context_processor
def inject_submit_post_form():
    from application.modules.posts.model import Category
    from application.modules.posts.forms import PostForm
    from application.modules.posts.model import PostType
    form = PostForm()
    form.category_id.choices = [(c.id, c.name) for c in Category.query.all()]
    form.post_type_id.choices = [(t.id, t.name) for t in PostType.query.all()]
    #form.post_type_id.data = 1
    return {'submit_post_form': form}