예제 #1
0
def prepare_redis():
    """
    Add default settings to Redis
    """
    cms = CMS()
    cms.site_title = 'YaCMS'
    cms.site_timezone = 'Europe/Amsterdam'
    cms.site_date_format = 'Do of MMMM, YYYY'
    cms.site_time_format = 'hh:mm A'

    try:
        cms.save()
        click.echo('initial redis settings saved successfully')
    except RedisError as e:
        click.echo('error occurred: {}'.format(str(e)))
예제 #2
0
def settings():
    obj = CMS()
    form = SettingsForm(site_title=CMS.get('site_title'),
                        site_timezone=CMS.get('site_timezone'),
                        site_date_format=CMS.get('site_date_format'),
                        site_time_format=CMS.get('site_time_format'))

    if request.method == 'POST' and form.validate():
        form.populate_obj(obj)
        msg, cat = obj.save()

        flash(msg, cat)

        return redirect(url_for('backend.settings'))

    return render_template('backend/cms/settings.j2', form=form)
예제 #3
0
def format_date(string):
    return get(string).format(CMS.get('site_date_format'))
예제 #4
0
def date(string):
    return get(string).replace(tzinfo=CMS.get('site_timezone')).humanize()
예제 #5
0
def format_time(string):
    return get(string).format(CMS.get('site_time_format'))