def save_new_question(): dict_of_question = request.form.to_dict() dict_of_question["user_id"] = data_manager.get_user_id_by_email(session["user"]) data_manager.add_new_question(dict_of_question) question_id = data_manager.get_last_question_by_title(dict_of_question["title"]) question_page_url = url_for("get_question_details", question_id=question_id) return redirect(question_page_url)
def add_question_route(): if request.method == 'GET': return render_template('ask_question.html') else: title = escape(request.form['title']) msg = escape(request.form['message']) data_manager.add_new_question(title, msg) question_id = data_manager.find_max_id() return redirect(url_for('question_route', question_id=question_id))
def route_add_question(): if 'user_name' in session: if request.method == 'POST': new_user_question = request.form data_manager.add_new_question(new_user_question) return redirect('/list') elif request.method == 'GET': return render_template("question.html") else: return redirect('/')
def route_ask_question(): if request.method == "POST": usr_input = request.form.to_dict() usr_input['submission_time'] = datetime.now() usr_input['user_id'] = session['user_id'] data_manager.add_new_question(usr_input) return redirect(url_for('route_list')) question_details = None return render_template('ask-question.html', question_details=question_details)
def route_ask_question(): if request.method == "GET": return render_template('ask-question.html') else: new_question = { "question_subject": request.form["question_subject"], "question_text": request.form["question_text"], "url": request.form["url"] } data_manager.add_new_question(new_question) return redirect("/")
def add_questions(): change_route_variable = 'question' if request.method == 'POST': question = { 'title': request.form.get('title'), 'message': request.form.get('message'), 'image': request.form.get('image') } dm.add_new_question(question) return redirect('/list') return render_template('add_comment.html', change_route_variable=change_route_variable)
def route_ask(): if request.method == 'GET': return render_template('ask.html', req_url=url_for('route_ask'), question={}) else: file = request.files['file'] if file and utility.allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) question = { "submission_time": datetime.fromtimestamp(utility.display_unix_time()), "view_number": 0, "vote_number": 0, 'title': request.form['title'], 'message': request.form['message'], 'image': UPLOAD_FOLDER + '/' + filename if file.filename else '', 'user_id': None } if 'user_id' in session: question['user_id'] = session['user_id'] tempid = data_manager.add_new_question(question) return redirect('/display/' + str(tempid))
def add_question(): if request.method == "GET": return render_template('new_question.html') new_question_all_data = data_manager.add_new_question() new_question_all_data.update({ 'title': request.form.get('question'), 'message': request.form.get('message'), 'image': request.form.get('image') }) data_manager.write_to_questions(new_question_all_data) return redirect( url_for('display_question', question_id=new_question_all_data['id']))
def save_question(title, message, image, user_id): return data_manager.add_new_question(title, message, image, user_id)
def check_length_message_question_db(inputs): if util.correct_length(inputs['message'], ">=", 10): data_manager.add_new_question(inputs['title'],inputs['message'],inputs['user_id'], ) return "Correct" else: return "Your message is too short. (Must be at least 10 characters long)"
def add_question(): if request.method == 'GET': return render_template('add-question.html') question_id = data_manager.add_new_question(request.form) return redirect(f'/question/{question_id}')