コード例 #1
0
ファイル: routes.py プロジェクト: hardcorepict/ToDoList
def user_task(user_name):
    form = AddTaskForm()
    if form.validate_on_submit():
        task = Task(content=form.content.data, owner=current_user)
        db.session.add(task)
        db.session.commit()
        flash('Your task was added')
        return redirect(url_for('user_task', user_name=current_user.username))
    tasks = Task.query.filter_by(user_id=current_user.id).order_by(Task.timestamp).all()
    return render_template('user_task.html', title='{}s task'.format(current_user.username), form=form, tasks=tasks)
コード例 #2
0
ファイル: routes.py プロジェクト: yonigottesman/timetodo
def index():
    form = AddTaskForm()
    if form.validate_on_submit():
        task = Task(description=form.description.data,
                    goal=form.goal.data,
                    owner=current_user,
                    progress=0)
        db.session.add(task)
        db.session.commit()
        return redirect(url_for('index'))

    tasks = current_user.tasks.all()
    return render_template("index.html",
                           title='Home Page',
                           tasks=tasks,
                           form=form)
コード例 #3
0
def index():
    add_task = AddTaskCase()
    add_task.repo = repo
    form = AddTaskForm()

    all_tasks = repo.get_all_tasks()

    if form.validate_on_submit():
        result = add_task.create(
            header=form.header.data,
            body=form.body.data,
            done=form.done.data,
        )
        flash(f"Task created : {result}")
        return redirect("/")
    return render_template("home.html", form=form, tasks=all_tasks)
コード例 #4
0
ファイル: routes.py プロジェクト: botasDEV/Projeto_3
def task_add(project_id):
    if not current_user.is_anonymous:
        form = AddTaskForm()
        if form.validate_on_submit():
            order_value = Task.query.filter_by(project_id=project_id).count()
            task = Task(title=form.title.data,
                        project_id=project_id,
                        due_date=form.due_date.data,
                        completed=False,
                        order=order_value + 1)

            db.session.add(task)
            db.session.commit()

            flash('Project added successfully!')
            return redirect(url_for('project', project_id=project_id))

        project_list = Project.query.filter_by(user_id=current_user.id).all()
        return render_template('task_add.html',
                               form=form,
                               projects=project_list)

    return redirect(url_for('login'))
コード例 #5
0
ファイル: views.py プロジェクト: velvokay/LogScribe
def index():
	form = AddTaskForm()
	editform = EditTaskForm()
	
	if request.method == 'POST':
		if form.validate() == False and editform.validate() == False:
			return render_template('index.html', form=form, editform=editform)
		elif form.validate() == True and editform.validate() == False:
			_task_user_id = None #form.task_user_id.data
			_task_date = "01/01/70" #form.task_date.data
			_task_address = "768 Vista Dr." #form.task_address.data
			newtask = Task(form.task_title.data, form.task_description.data, _task_date, _task_address)
			db.session.add(newtask)
			db.session.commit()
			#Post commit
			
			title = Task.query.filter_by(task_title=form.task_title.data).first()
			description = Task.query.filter_by(task_description=form.task_description.data).first()
			db.session.commit()
			
			session['task_title'] =  title.task_title #newtask.task_title
			session['task_description'] = description.task_description #newtask.task_description
			#=====================
			#edit
			#=====================
			
			# edittask = Task(form.task_title.data, form.task_description.data, editform.task_date.data, editform.task_address.data)
			# db.session.add(edittask)
			# db.session.commit()
			
			# title = Task.query.filter_by(task_title=form.task_title.data).first()
			# description = Task.query.filter_by(task_description=form.task_description.data).first()
			# session['task_title'] = title.task_title #newtask.task_title
			# session['task_description'] = description.task_description #newtask.task_description
			# db.session.commit()
			
			return redirect(url_for('index'))
			
		else:
			_task_user_id = None #form.task_user_id.data
			_task_date = "01/01/70" #form.task_date.data
			_task_address = "768 Vista Dr." #form.task_address.data
			newtask = Task(form.task_title.data, form.task_description.data, _task_date, _task_address)
			db.session.add(newtask)
			db.session.commit()
			#Post commit
			
			title = Task.query.filter_by(task_title=form.task_title.data).first()
			description = Task.query.filter_by(task_description=form.task_description.data).first()
			db.session.commit()
			
			session['task_title'] =  title.task_title #newtask.task_title
			session['task_description'] = description.task_description #newtask.task_description
			# EDIT
		
			edittask = Task(form.task_title.data, form.task_description.data, editform.task_date.data, editform.task_address.data)
			db.session.add(edittask)
			db.session.commit()
			#Post commit
			
			date = Task.query.filter_by(task_date=editform.task_date.data).first()
			address = Task.query.filter_by(task_address=editform.task_address.data).first()
			session['task_date'] = date.task_date
			session['task_address'] = address.task_address
			db.session.commit()
			
			return redirect(url_for('index'))
			
			
	elif request.method == 'GET':
		return render_template('index.html', form=form, editform=editform)