def user_page(name): if request.method == 'POST': title = request.form['title'] details = request.form['details'] deadline = request.form['deadline'] user_id = get_user_info(name)['id'] create_user_task(user_id, title, details, deadline) return redirect('/users/'+name) user_tasks = get_user_tasks(name) access_id = None if get_user_info(name) != None: access_id = get_user_info(name)["access_id"] return render_template('user.html', name=name, tasks=user_tasks, access_id=access_id)
def user_page(name): if request.method == 'POST': title = request.form['title'] details = request.form['details'] deadline = request.form['deadline'] try: author_id = get_id_by_name(name) except AccountNotFound: abort(404) create_user_task(author_id, title, details, deadline) try: user_tasks = get_user_tasks(name) except AccountNotFound: abort(404) return render_template('user.html', name=name, tasks=user_tasks)
def fill_tasks(): with open('MOCK_TASKS.json') as f: mock = json.load(f) for i in mock: create_user_task(**i)
def create_task(task): if 'account' in session: user_id = get_user_info(session['account'])['id'] create_user_task(user_id, task) return redirect(url_for('user_page', name=session['account'])) return render_template('404.html')