本文整理汇总了Python中forms.CategoryForm.is_submitted方法的典型用法代码示例。如果您正苦于以下问题:Python CategoryForm.is_submitted方法的具体用法?Python CategoryForm.is_submitted怎么用?Python CategoryForm.is_submitted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.CategoryForm
的用法示例。
在下文中一共展示了CategoryForm.is_submitted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from forms import CategoryForm [as 别名]
# 或者: from forms.CategoryForm import is_submitted [as 别名]
def post(self):
form = CategoryForm()
if form.is_submitted():
try:
if not form.validate():
raise Exception(_('ERROR_INVALID_SUBMISSION'))
category = Category.create()
if not form.slug.data:
form.slug.data = form.name.data
form.slug.data = Category.urlify(form.slug.data)
form.populate_obj(category)
category.save()
return render_view(url_for('CategoriesView:put', id=category.id),
message=_('CATEGORY_CREATE_SUCESS'),
redirect=True)
except Exception as e:
flash(e.message, 'error')
return render_view('admin/categories/add.html', form=form)
示例2: put
# 需要导入模块: from forms import CategoryForm [as 别名]
# 或者: from forms.CategoryForm import is_submitted [as 别名]
def put(self, id):
category = Category.get_by_id(id)
if category is None:
return render_view(url_for('CategoriesView:index'),
status=False,
redirect=True,
message=_('CATEGORY_NOT_FOUND'))
if not category.can_edit():
abort(401)
form = CategoryForm(category=category)
if form.is_submitted():
try:
if not form.validate():
raise Exception(_('ERROR_INVALID_SUBMISSION'))
if not form.slug.data:
form.slug.data = form.name.data
if category.slug != form.slug.data:
form.slug.data = Category.urlify(form.slug.data)
form.populate_obj(category)
category.save()
return render_view(url_for('CategoriesView:put', id=category.id),
message=_('CATEGORY_SAVE_SUCCESS'),
redirect=True)
except Exception as e:
flash(e.message, 'error')
return render_view('admin/categories/edit.html',
form=form,
category=category)