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)))
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)
def format_date(string): return get(string).format(CMS.get('site_date_format'))
def date(string): return get(string).replace(tzinfo=CMS.get('site_timezone')).humanize()
def format_time(string): return get(string).format(CMS.get('site_time_format'))