예제 #1
0
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')
예제 #2
0
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')
예제 #3
0
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)
예제 #4
0
def task():
    form = TaskForm()
    return render_template('task.html',
                           title='Assign Task',
                           form=form,
                           recipient_user=request.args.get('user'))
예제 #5
0
def reject():
    form = TaskForm()
    return render_template('reject.html', title=' Reject Page', form=form)
예제 #6
0
def accept():
    form = TaskForm()
    return render_template('accept.html', title=' Accept Page ', form=form)