示例#1
0
def addTask(request):
    if request.method == 'POST':
        form = AddTask(request.POST)
        if form.is_valid():
            name = request.POST.get('name', '')
            description = request.POST.get('description', '')
            date = request.POST.get('date', '')
            completed = request.POST.get('completed', False)
            task = Task(name=name,
                        description=description,
                        date=date,
                        completed=completed)
            task.save()
            return render(
                request, 'app/thanks.html', {
                    'title': 'Thanks',
                    'year': datetime.now().year,
                    'message': 'task added',
                })
    else:
        form = AddTask()
    return render(
        request, 'app/addtask.html', {
            'form': form,
            'title': 'AddTask',
            'year': datetime.now().year,
            'massage': 'addtask',
        })
示例#2
0
def new_task():
    form = AddTask(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        new_task = FTasks(form.name.data, form.due_date.data, form.priority.data, "1")
        db.session.add(new_task)
        db.session.commit()
        flash("New entry was successfully posted. Thanks.")
    return redirect(url_for("tasks"))
示例#3
0
def new_task():
    form = AddTask(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        new_task = FTasks(form.name.data, form.due_date.data,
                          form.priority.data, '1')
        db.session.add(new_task)
        db.session.commit()
        flash('New entry was successfully posted. Thanks.')
    return redirect(url_for('tasks'))
示例#4
0
文件: views.py 项目: sunnyye28/Tasker
def addTask():
    error = None
    form = AddTask(request.form, csrf_enabled=False)

    if form.validate_on_submit():
        new_task = Task(form.name.data, form.due_date.data, form.priority.data,
                        form.status.data)
        db.session.add(new_task)
        db.session.commit()
    else:
        #error = "Please complete all required fields."
        flash_errors(form)
    return redirect(url_for('main'))
示例#5
0
def addTask(request):
    if request.method == 'POST':
        form = AddTask(request.POST)
        if form.is_valid():
            name = request.POST.get('name', '')
            description = request.POST.get('description', '')
            date = request.POST.get('date', '')
            completed = request.POST.get('completed', False)
            task = Task(name=name, description=description, date=date, completed=completed)
            task.save()
            return render(request, 'app/thanks.html', {'title':'Thanks', 'year':datetime.now().year, 'message': 'task added',})
    else:
        form = AddTask()
    return render(request, 'app/addtask.html', {'form': form, 'title':'AddTask', 'year':datetime.now().year, 'massage': 'addtask',})
示例#6
0
def new_task():
    form = AddTask(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        new_task = FTasks(
                    form.name.data,
                    form.due_date.data,
                    form.priority.data,
                    form.posted_date.data,
                    '1',
                    session['user_id']
                    )
        db.session.add(new_task)
        db.session.commit()
        flash('New entry was successfully posted. Thanks.')
    return redirect(url_for('tasks'))  
示例#7
0
def tasks():
    open_tasks = db.session.query(FTasks).filter_by(status='1').order_by(
                    FTasks.due_date.asc())
    closed_tasks = db.session.query(FTasks).filter_by(status='0').order_by(
                    FTasks.due_date.asc())
    return render_template('tasks.html',form = AddTask(request.form),
                            open_tasks=open_tasks, closed_tasks=closed_tasks)
示例#8
0
文件: views.py 项目: sunnyye28/Tasker
def addTask():
	error = None
	form = AddTask(request.form, csrf_enabled=False)
	
	if form.validate_on_submit():
		new_task = Task(
					form.name.data,
					form.due_date.data,
					form.priority.data,
					form.status.data
					)
		db.session.add(new_task)
		db.session.commit()
	else:
		#error = "Please complete all required fields."
		flash_errors(form)
	return redirect(url_for('main'))
示例#9
0
def add_task():
    if current_user.type == 0:
        return redirect(url_for('index'))
    form = AddTask()
    form.user_id.choices = [(user.id, user.username)
                            for user in User.query.all()]
    if form.validate_on_submit():
        task = Task(task=form.task.data,
                    author_id=current_user.id,
                    user_id=form.user_id.data,
                    timestamp=datetime.utcnow())
        db.session.add(task)
        db.session.commit()
        flash('Задача назначенна', 'primary')
        return redirect(url_for('add_task'))
    return render_template('add_task.html',
                           title='Назначить задачу',
                           form=form)
示例#10
0
def add_task():
    form = AddTask()
    form.users_id.choices = [
        (user.id, user.login) for user in User.query.all()
    ]
    task_ = {'author_id': current_user.id}
    if form.validate_on_submit():
        task_ = Task.create({
            'title': form.title.data,
            'description': form.description.data,
            'author_id': current_user.id,
            'users_id': form.users_id.data,
        })
        flash('Task successfully assigned', 'primary')

    return render_template(
        'add_task.html', title='Add task', form=form, task=task_,
        current_user=current_user
    )
示例#11
0
def index():
    form = AddTask()
    form2 = AddTodo()
    # newtaskTime = None
    if form.validate_on_submit():
        newTask = form.newtask.data
        # if form.time.data:
        #     newtaskTime = form.time.data
        newTask = Task(task=newTask)
        db.session.add(newTask)
        db.session.commit()
        return redirect(url_for('index'))
    taskList = Task.query.all()
    completed = Task.query.filter_by(status=1)
    return render_template('index.html',
                           title='Home',
                           form=form,
                           task=taskList,
                           completed=completed,
                           form2=form2)