本文整理汇总了Python中forms.TaskForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python TaskForm.validate_on_submit方法的具体用法?Python TaskForm.validate_on_submit怎么用?Python TaskForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.TaskForm
的用法示例。
在下文中一共展示了TaskForm.validate_on_submit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate_on_submit [as 别名]
def index():
form = TaskForm()
if form.validate_on_submit():
r.table('todos').insert({"name":form.label.data}).run(g.rdb_conn)
return redirect(url_for('index'))
selection = list(r.table('todos').run(g.rdb_conn))
return render_template('index.html', form = form, tasks = selection)
示例2: tasks
# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate_on_submit [as 别名]
def tasks():
# imported our TaskForm class, instantiated an object from it,
#and sent it down to the template where forms is used.
form = TaskForm(request.form)
tasks = Task.query.all()
# for task in tasks:
# db.session.delete(task)
# db.session.commit()
if request.method == 'POST' and form.validate_on_submit():
flash('Created Async Task!')
#save numberOfSeconds in a session hash
session['numberOfSeconds'] = form.numberOfSeconds.data
time = int(session['numberOfSeconds'])
#START OF ASYNC SLEEP CALL#
t1 = start_sleep.delay(time)
session['TASK_ID'] = t1.id
#add new async task to database
new_task = Task(time = int(session['numberOfSeconds']),status= t1.ready(),key =session['TASK_ID'])
db.session.add(new_task)
db.session.commit()
return redirect(url_for('tasks'))
return render_template('tasks.html',
title = 'Amadeus Task',
form = form,
tasks = tasks)
示例3: index
# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate_on_submit [as 别名]
def index():
form = TaskForm()
if form.validate_on_submit(): # if it is a POST request
task = Task(label = form.label.data)
task.save()
return redirect(url_for('index'))
tasks = Task.objects.all()
return render_template('index.html', form = form, tasks = tasks)
示例4: task
# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate_on_submit [as 别名]
def task(id_project, id_task=None):
project = Project.query.get(id_project)
from forms import TaskForm
if id_task != None:
task = task.query.get(id_task)
action = "Save"
else:
task = Task()
action = "Add"
form = TaskForm(obj=task)
if form.validate_on_submit():
form.populate_obj(task)
db.session.add(task)
db.session.commit()
return redirect('/tasks')
return render_template('project/task/form.html', form=form, action=action, project=project)
示例5: add
# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate_on_submit [as 别名]
def add():
# Create a new chore form
form = TaskForm()
# Check for a POST and validate the form data
if form.validate_on_submit():
# Create a new chore with the current user as the parent
newTask = Task(parent=ndb.Key("User", users.get_current_user().email()))
# Fill in the details and insert it into the database
newTask.name = form.name.data
newTask.description = form.description.data
newTask.points = form.points.data
newTask.point_type = form.point_type.data
newTask.put()
# Automatically redirect the user to the chore list
return redirect(url_for('.list'))
# If not POSTing then display the default new chore form
return render_template('tasks/new_task.html', form=form)
示例6: create_tasks
# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate_on_submit [as 别名]
def create_tasks(record_id=False, **post):
user = False
project_id = request.args.get('project_id', 0, type=int)
form = TaskForm()
if project_id:
form.project_id.data = project_id
state = request.args.get('state', '', type=str)
if project_id:
form.state.data = state
if form.validate_on_submit():
values = {
'name': form.name.data,
'description': form.description.data,
'color': form.color.data,
'date': form.date.data,
'user_id': form.user_id.data,
'project_id': form.project_id.data,
'date_deadline': form.date_deadline.data,
'state': form.state.data
}
if record_id:
table_registry.tasks.write([record_id], values)
else:
table_registry.tasks.create(values)
return json.dumps({'redirect': url_for('tasks') + '/' + str(form.project_id.data)})
elif record_id:
project_data = table_registry.tasks.search_read([['id', '=', record_id]])[0]
form.name.data = project_data['name']
form.description.data = project_data['description']
form.color.data = project_data['color']
form.date.data = project_data['date'].strftime('%m/%d/%Y %I:%M %p')
form.date_deadline.data = project_data['date_deadline'].strftime('%m/%d/%Y %I:%M %p')
form.project_id.data = project_data['project_id']._get()['id']
user = project_data['user_id']._get()
form.user_id.data = user['id']
form.state.data = project_data['state']
return render_template('backend/task_model.html', form=form, record_id=record_id and str(record_id), user_name=user and user['name'] or "")
示例7: goaltree
# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import validate_on_submit [as 别名]
def goaltree(goalid):
me = User.objects(id = g.user.id).first()
goal = Goal.objects(id = goalid).first()
tasks = Task.objects(goal = goalid).order_by('-end')
form = TaskForm()
if form.validate_on_submit():
task = Task(goal=goal,name = form.name.data, description = form.description.data, end = form.end.data, people = [me])
task.save()
feeditem = TaskRequest(message='A task was added to a goal you are working on',user=me,task=task,goal=goal)
for person in goal.people:
if person != me:
person.feed.append(feeditem)
person.save()
return redirect(url_for('goaltree',goalid=goalid))
megacounts = {}
for person in goal.people:
counts = {'active':[],'completed':[],'missed':[]}
for task in tasks:
if person in task.people:
counts['active'].append(task)
if person in task.completed:
counts['completed'].append(task)
if person in task.missed:
counts['missed'].append(task)
megacounts[person.id] = counts
return render_template('goaltreelite.html',me = me, goal = goal, tasks = tasks, today = datetime.datetime.now(), form = form, allCounts=megacounts)