コード例 #1
0
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)
コード例 #2
0
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))
コード例 #3
0
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('/')
コード例 #4
0
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)
コード例 #5
0
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("/")
コード例 #6
0
ファイル: app.py プロジェクト: KatyIftimie/AskMate_public
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)
コード例 #7
0
ファイル: server.py プロジェクト: TiborVlasics/ask-mate
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))
コード例 #8
0
ファイル: server.py プロジェクト: boroslizi/AskMate
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']))
コード例 #9
0
def save_question(title, message, image, user_id):
    return data_manager.add_new_question(title, message, image, user_id)
コード例 #10
0
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)"
コード例 #11
0
ファイル: server.py プロジェクト: gergomahler/ask-mate-python
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}')