def new_task(): tasks = Task.query.filter_by(author=current_user).all() if len(tasks) >= 50: flash('You can not add more than 50 tasks', 'danger') return redirect(url_for('home')) else: form = TaskForm() if form.validate_on_submit(): file = None if form.file.data: file = save_picture(form.file.data) task = Task(title=form.title.data, content=form.content.data, author=current_user, due_date=form.due_date.data, completion=form.completion.data, completion_date=form.completion_date.data, attachment=file) print('lol : ', file) db.session.add(task) db.session.commit() flash('Your task has been created!', 'success') return redirect(url_for('home')) return render_template('create_task.html', title='New Task', form=form, legend='New Task')
def update_task(task_id): task = Task.query.get_or_404(task_id) if task.author != current_user: abort(403) form = TaskForm() if form.validate_on_submit(): task.title = form.title.data task.content = form.content.data db.session.commit() flash('Your task has been updated!', 'success') return redirect(url_for('task', task_id=task.id)) elif request.method == 'GET': form.title.data = task.title form.content.data = task.content return render_template('create_task.html', title='Update Task', form=form, legend='Update Task')
def send_task(recipient): request_data = request.form user = User.query.filter_by(username=recipient).first_or_404() form = TaskForm() if request_data: print(request_data) msg = Task(author=current_user, recipient=user, title=request_data['title'], body=request_data['body']) db.session.add(msg) db.session.commit() flash('Your message has been sent.') return redirect(url_for('home', username=recipient)) return render_template('task.html', title=('Send Message'), form=form, recipient=recipient)
def task(): form = TaskForm() return render_template('task.html', title='Assign Task', form=form, recipient_user=request.args.get('user'))
def reject(): form = TaskForm() return render_template('reject.html', title=' Reject Page', form=form)
def accept(): form = TaskForm() return render_template('accept.html', title=' Accept Page ', form=form)