Exemple #1
0
def task_add(request):
    '''add task to project'''
    pid = int(request.POST.get('pid',0))
    task = Task()
    task.name = request.POST.get('task_name')
    task.project = get_object_or_404(Project,id__exact = pid)
    priority = request.POST.get('priority')
    if priority:
        task.priority = priority
    else:
        task.priority = TASK_PRIORITY['medium']
    task.completed = 0
    task.save()
    #add project task count
    task.project.tasks += 1
    task.project.save()
    #return HttpResponseRedirect('/todo/')
    return HttpResponse('success')
Exemple #2
0
def task_add(request):
    '''add task to project'''
    pid = int(request.POST.get('pid', 0))
    task = Task()
    task.name = request.POST.get('task_name')
    task.project = get_object_or_404(Project, id__exact=pid)
    priority = request.POST.get('priority')
    if priority:
        task.priority = priority
    else:
        task.priority = TASK_PRIORITY['medium']
    task.completed = 0
    task.save()
    #add project task count
    task.project.tasks += 1
    task.project.save()
    #return HttpResponseRedirect('/todo/')
    return HttpResponse('success')
Exemple #3
0
def home():
	form = TaskForm()
	list1 = Task.query.filter_by(category = 1, status = 1)
	list2 = Task.query.filter_by(category = 2, status = 1)
	list3 = Task.query.filter_by(category = 3, status = 1)
	list4 = Task.query.filter_by(category = 4, status = 1)
	list5 = Task.query.filter_by(status = 2)
	empty = 0
	if not list5:
		empty = 1
	if form.validate_on_submit():
		newtitle = form.title.data
		newpriority = form.priority.data
		newcategory = form.category.data
		task = Task()
		task.name = newtitle
		if newcategory == '1':
			task.category = 1
		elif newcategory == '2':
			task.category = 2
		elif newcategory == '3':
			task.category = 3
		elif newcategory == '4':
			task.category = 4

		if newpriority == '1':
			task.priority = 1
		elif newpriority == '2':
			task.priority = 2
		elif newpriority == '3':
			task.priority = 3
		
		task.author = current_user
		task.status = 1
		db.session.add(task)
		db.session.commit()
		return redirect(url_for('home'))

	return render_template('home.html', form = form, list1 = list1, list2 = list2, list3 = list3, list4 =list4, list5 = list5, empty = empty)