本文整理汇总了Python中models.Setting.setting_text方法的典型用法代码示例。如果您正苦于以下问题:Python Setting.setting_text方法的具体用法?Python Setting.setting_text怎么用?Python Setting.setting_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Setting
的用法示例。
在下文中一共展示了Setting.setting_text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import setting_text [as 别名]
def index():
if request.method == "GET":
# find the latest setting record
settings = Setting.query.order_by(desc(Setting.id)).all()
if len(settings) > 0:
setting = settings[0]
else:
setting = None
return render_template("admin/settings.html", setting=setting)
elif request.method == "POST":
# get post data
setting_id = request.form['setting_id']
host = request.form['host']
headline = request.form['headline']
setting_text = request.form['text']
start_date = request.form['start_date']
current_app.logger.info("%s, %s, %s, %s, %s" % (setting_id, host, headline, setting_text, start_date))
# find or create setting object
setting = None
if setting_id:
setting = Setting.query.get(int(setting_id))
if not setting:
setting = Setting()
# udpate db
setting.host = host
setting.headline = headline
setting.setting_text = setting_text
setting.start_date = start_date
db_session.add(setting)
db_session.commit()
flash(_("Setting updated!"))
return redirect(url_for(".index"))