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', })
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"))
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'))
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'))
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',})
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'))
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)
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'))
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)
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 )
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)