本文整理匯總了Python中forms.GroupForm.validate方法的典型用法代碼示例。如果您正苦於以下問題:Python GroupForm.validate方法的具體用法?Python GroupForm.validate怎麽用?Python GroupForm.validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類forms.GroupForm
的用法示例。
在下文中一共展示了GroupForm.validate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: edit_group
# 需要導入模塊: from forms import GroupForm [as 別名]
# 或者: from forms.GroupForm import validate [as 別名]
def edit_group(grupo):
# grupo = Grupo.objects.get_or_404(nombre=grupo)
grupo = Grupo.objects.get_or_create(nombre=grupo,defaults={'horario': 'Sin definir'})
grupo_id=grupo[0].id
# if len(grupo[0].horario)<1:
# grupo[0].horario = 'Sin definir'
# user_json=usuario
# uuu = [{'nombre':'nombre','username':'username'}]
# post = Usuario.objects.get_or_404(username=username)
form = GroupForm(request.form,grupo[0])
if request.method == 'POST':
if form.validate() == False:
flash('Todos los campos son necesarios.')
return render_template('usuarios/groups.html', form=form, data_type="Grupos", action="Editar")
else:
# flash('Valores por defecto.')
g=Grupo.objects.get(id=grupo_id)
g.update(set__nombre=form.nombre.data)
g.update(set__horario=form.horario.data)
# grupo[0].nombre=form.nombre.data
# grupo[0].horario=form.horario.data
# grupo[0].save()
# return render_template('usuarios/groups.html', form=form, data_type="Grupos", action="Editar")
grupos = Grupo.objects.all()
return render_template ('usuarios/groups.html', grupos=grupos, action="Listar")
# return render_template('grupos.html')
elif request.method == 'GET':
return render_template('usuarios/groups.html', form=form, data_type="Grupos", action="Editar")
示例2: addGroup
# 需要導入模塊: from forms import GroupForm [as 別名]
# 或者: from forms.GroupForm import validate [as 別名]
def addGroup():
if 'email' not in session:
return redirect(url_for('signin'))
user = Smarketer.query.filter_by(username = session['email']).first()
if user is None:
return redirect(url_for('signin'))
else:
form = GroupForm()
if request.method == 'POST':
if form.validate() == False:
return render_template('addGroup.html', form=form)
else:
totalTitle = form.groupTitle.data + " - " + form.groupID.data
newGroup = Group(form.groupID.data, totalTitle)
db.session.add(newGroup)
db.session.commit()
form.groupID.data = ""
form.groupTitle.data = ""
return render_template('addGroup.html', form=form, success=True)
elif request.method == 'GET':
return render_template('addGroup.html', form=form)
示例3: groups
# 需要導入模塊: from forms import GroupForm [as 別名]
# 或者: from forms.GroupForm import validate [as 別名]
def groups(group_id=None):
form = GroupForm(request.form)
if request.method == 'POST':
if not form.validate():
pass
else:
pass
return render_template('groups.html', user=get_user(), form=form)