当前位置: 首页>>代码示例>>Python>>正文


Python TaskForm.validate方法代码示例

本文整理汇总了Python中forms.TaskForm.validate方法的典型用法代码示例。如果您正苦于以下问题:Python TaskForm.validate方法的具体用法?Python TaskForm.validate怎么用?Python TaskForm.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.TaskForm的用法示例。


在下文中一共展示了TaskForm.validate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: task

# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate [as 别名]
def task():
	form = TaskForm()
	if request.method == "POST":
		if form.validate() == False:
			flash("All fields are required")
			return render_template("task.html",form=form)
		else:
			
			task_name = form.name.data
			task_client = form.client.data
			task_capabilities = form.capabilities.data
			task_duration = int(form.duration.data)
			#insert values to Task table
				
			task_msg = task_insert(task_name,task_client,task_capabilities,task_duration)
				
                         
			
			return jsonify(name =task_name,
					client=task_client, 
					capabilities=task_capabilities,
					duration=task_duration,result = task_msg)
			#return render_template("success.html",form=form)
	elif request.method == 'GET':
		return render_template("task.html",form=form)
开发者ID:ashaudupa,项目名称:flask,代码行数:27,代码来源:views.py

示例2: new_task

# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate [as 别名]
def new_task():
    form = TaskForm(request.form)
    if request.method == 'POST' and form.validate():
        task = Task(form.name.data, form.text.data, form.memory.data, form.time_limit.data, g.user)
        task.save()
        return redirect(url_for('task', task_id=task.task_id))

    return render_template('task_form.html', form=form)
开发者ID:drakipovic,项目名称:Penguin,代码行数:10,代码来源:views.py

示例3: edit_task

# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate [as 别名]
def edit_task(task_id):
    task = Task.query.get(task_id)
    if g.user.user_id != task.author_id:
        flash('You do not have proper authorization to do this!', 'danger')
        return redirect('/task/' + str(task_id))

    form = TaskForm(obj=task)
    if request.method == 'POST' and form.validate():
        form = TaskForm(request.form)
        form.populate_obj(task)
        task.save()
        return redirect(url_for('task', task_id=task.task_id))

    return render_template('task_form.html', form=form, edit=True)
开发者ID:drakipovic,项目名称:Penguin,代码行数:16,代码来源:views.py

示例4: add_task

# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate [as 别名]
def add_task():
    form = TaskForm(request.form)
    nowdate=datetime.now()
    if request.method == 'POST' and form.validate():
          task = Task(form.content.data,form.deadline.data)
          if not form.assign.data:
             assignlist = AssignList(user=g.user.username)
             task.assignlist.append(assignlist)
          else:
             for user in form.assign.data.split():
                 assignlist = AssignList(user=user)
                 task.assignlist.append(assignlist)
          task.save()
          return redirect('/task/pending')
    return render_template('add.html', form=form,nowdate=nowdate)
开发者ID:Windfarer,项目名称:todo,代码行数:17,代码来源:views.py

示例5: tasks

# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate [as 别名]
def tasks():
	
	if 'userid' in session:	
		user = User.query.get_or_404(session['userid'])	
		
		if request.method == 'POST':
			form = TaskForm(request.form)
			if form.validate():
				newtask = Task(form.title.data, user, None, form.value.data)
				db.session.add(newtask)
				db.session.commit()
				return redirect(url_for('tasks'))
			else:
				tasks = user.tasks.filter(Task.complete == False).order_by(desc(Task.dateadded)).all()	
				return render_template('tasks.html', username=user.username, points=user.points, tasks=tasks, form=form, idform=TaskIdForm(), updateform=TaskUpdateForm(), containerclass="listcontainer")

		else:
			tasks = user.tasks.filter(Task.complete == False).order_by(desc(Task.dateadded)).all()			
			return render_template('tasks.html', username=user.username, points=user.points, tasks=tasks, form=TaskForm(), idform=TaskIdForm(), updateform=TaskUpdateForm(), containerclass="listcontainer")
	# if no session, display default home page. TODO: convert to splash page
	else:
		return redirect(url_for('front'))
开发者ID:pinebender,项目名称:landr-heroku,代码行数:24,代码来源:views.py

示例6: edit_task

# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate [as 别名]
def edit_task(task_id):
    form=TaskForm(request.form)
    task=Task.objects(id=ObjectId(task_id)).first()
    namelist=[]
    for i in task.assignlist:
        namelist.append(i.user)
    namelist=" ".join(namelist)
    if request.method == 'POST' and form.validate():
        task.content=form.content.data
        task.deadline=form.deadline.data
        task.assignlist=[]
        recipients=[]
        if not form.assign.data:
           task.assignlist.append(AssignList(user=g.user.username))
        else:
           for user in form.assign.data.split():
               if User.objects(username=user):
                   assign = AssignList(user=user)
                   task.assignlist.append(assign)
        task.save()
        
        return redirect('/task/pending')
    return render_template('edit.html', form=form, task=task,task_id=task_id,namelist=namelist)
开发者ID:Windfarer,项目名称:todo,代码行数:25,代码来源:views.py


注:本文中的forms.TaskForm.validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。