本文整理匯總了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)