本文整理汇总了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)