def edit_question(question_id): question_data = data_handler.get_one_question(question_id) if request.method == 'POST': data_handler.edit_question(request, question_data, send_from_directory, app) return redirect(url_for('show_answers', question_id=question_id)) return render_template('question/edit.html', title='Edit Question', question_id=question_id, question_data=question_data, username=session['username'])
def route_edit_a_question(question_id): question = data_handler.get_data_by_question_id('question', question_id)[0] if request.method == "POST": message = request.form['message'] image = request.form['image'] data_handler.edit_question('question', question_id, message, image) return redirect(f'/question/{question_id}') return render_template('edit-a-question.html', question=question)
def route_edit_answer(question_id, answer_id): if request.method == 'GET': question = data_handler.get_data_by_question_id( 'question', question_id)[0] answer = data_handler.get_answer_by_id(answer_id)[0] return render_template('edit-answer.html', question=question, answer=answer) if request.method == 'POST': message = request.form['message'] image = request.form['image'] data_handler.edit_question('answer', answer_id, message, image) return redirect(f'/question/{question_id}')
def route_edit_question(question_id): if request.method == "GET": username = session["username"] question_title = data_handler.get_question_title(question_id) question_message = data_handler.get_question_message(question_id) return render_template("edit-question.html", question_title=question_title, question_message=question_message, question_id=question_id,username=username) if request.method == "POST": if request.files['file']: file = request.files['file'] file.save(path + "/static/images/" + file.filename) data_handler.edit_question(question_id, request.form.get("title"), request.form.get("message"), file.filename) else: data_handler.edit_question(question_id, request.form.get("title"), request.form.get("message"), data_handler.get_image(question_id)) return redirect('/list')
def edit_question(question_id): if request.method == 'POST': user_question = { 'id': question_id, 'title': request.form['title'], 'message': request.form['message'], 'image': None } data_handler.edit_question(user_question) if request.form['tag_selector'] and int(question_id) not in [tag['question_id'] for tag in data_handler.get_question_tags()]: data_handler.set_question_tag(question_id, int(request.form['tag_selector'])) else: data_handler.update_question_tag(question_id, int(request.form['tag_selector'])) return redirect(url_for('question', question_id=question_id)) return render_template('edit_question.html', question=data_handler.get_selected_question(question_id), tags=data_handler.get_tags())
def edit_question(question_id): if request.method == 'POST': question = { 'id': request.form.get('id'), 'submission_time': request.form.get('submission_time'), 'view_number': request.form.get('view_number'), 'vote_number': request.form.get('vote_number'), 'title': request.form.get('title'), 'message': request.form.get('message') } data_handler.edit_question(question) return redirect(url_for('view_question', question_id=question_id)) question = data_handler.get_question_data_by_id(question_id)[0] return render_template('add_edit_questions.html', page_title='Edit question', button_title='Edit question', question=question, question_id=question_id)
def edit(question_id): if request.method == 'POST': form_id = request.form.get('form_id') form_title = request.form.get('title') if question_id == form_id: question_content = { 'id': question_id, 'submission_time': request.form.get('submission_time'), 'title': request.form.get('title'), 'view_number': request.form.get('view_number'), 'vote_number': request.form.get('vote_number'), 'message': request.form.get('message'), 'image': request.form.get('image') } data.edit_question(question_content) return redirect(url_for('list')) question_content = data.get_all_questions(question_id) return render_template('edit.html', question_content=question_content, question_id=question_id )
def edit_question(question_id): question_by_id = data_handler.get_questions_by_id( question_id, data_handler.QUESTION_FILE) if request.method == 'POST': edited_question_data = data_handler.edit_question( request.form.items(), question_id) all_question = data_handler.get_all_question() connection.write_csv_file(data_handler.QUESTION_FILE, all_question, data_handler.QUESTIONS_HEADER, question_id) connection.append_csv_file(data_handler.QUESTION_FILE, edited_question_data.values()) return redirect("/question/" + question_id) return render_template("edit_question.html", question_id=question_id, message=question_by_id['message'], title=question_by_id['title'])