当前位置: 首页>>代码示例>>Python>>正文


Python Setting.headline方法代码示例

本文整理汇总了Python中models.Setting.headline方法的典型用法代码示例。如果您正苦于以下问题:Python Setting.headline方法的具体用法?Python Setting.headline怎么用?Python Setting.headline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Setting的用法示例。


在下文中一共展示了Setting.headline方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import headline [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"))
开发者ID:ChinaHackers,项目名称:timeline-gallery-in-openshift,代码行数:36,代码来源:settings.py


注:本文中的models.Setting.headline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。