本文整理汇总了Python中models.Page.status_id方法的典型用法代码示例。如果您正苦于以下问题:Python Page.status_id方法的具体用法?Python Page.status_id怎么用?Python Page.status_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Page
的用法示例。
在下文中一共展示了Page.status_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_page
# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import status_id [as 别名]
def save_page(page_id=None):
"""Save Page to database
If page_id is None a new Page will be inserted in the database. Otherwise
the existing Page will be updated.
"""
message = 'Page updated'
page_form = PageForm(request.form)
if not page_form.validate():
flash('ERROR: errors detected. Page NOT saved!', category='error')
return edit_page(page_id=page_id, page_form=page_form)
if page_id is None:
page = Page(request.form['title'], request.form['content'])
page.status_id = 1
page.user_id = session['user_id']
page.createdate = datetime.now()
else:
page = get_page(page_id)
page_form.populate_obj(page)
page.lastmoddate = datetime.now()
# compile input to html
page.compile(app.config['REPL_TAGS'])
# update pubdate if page's pubdate is None and its status is set
# to public
if request.form['status'] == 'public' and \
unicode(page.status) != 'public' and \
page.pubdate is None:
page.pubdate = datetime.now()
page.status = get_status(request.form['status'])
if page.slug is None:
page.slug = slugify(page.title)
if page_id is None:
db_session.add(page)
message = 'New page was successfully added'
db_session.commit()
flash(message)
return redirect(url_for('edit_page', page_id=page.id))