예제 #1
0
def question_comment_route(question_id):
    if session.get('username') is not None:
        if request.method == "GET":
            return render_template("add-question-comment.html", question_id=question_id)
        elif request.method == "POST":
            message=request.form['question-comment']
            question_id=question_id
            user_id = session['user_id']
            data_manager.add_question_comment(question_id,message,user_id)
            return redirect(url_for("question_route",id=question_id))
    else:
        flash('You must login before using features', 'no_user')
        return redirect(url_for('question_route', id=question_id))
예제 #2
0
def add_question_comment(question_id):
    change_route_variable = 'question_comment'
    if request.method == 'POST':
        comment = {
            'question_id': question_id,
            'message': request.form.get('message')
        }
        dm.add_question_comment(comment)
        return redirect(
            url_for("show_comments_on_question", question_id=question_id))
    return render_template('add_comment.html',
                           question_id=question_id,
                           change_route_variable=change_route_variable)
예제 #3
0
def route_add_question_comment(question_id):
    answer_id = None

    if request.method == 'POST':
        message = request.form['message']
        message=message.replace("'","''")
        data_manager.add_question_comment(message=message,
                                          question_id=question_id,
                                          answer_id=answer_id)
        return redirect(url_for('route_question', question_id=question_id))

    return render_template('add_comment.html',
                           question_id=question_id,
                           answer_id=answer_id)
예제 #4
0
def new_question_comment(question_id):
    if request.method == 'POST':
        data_manager.add_question_comment(
            question_id, request.form['message'],
            data_manager.get_user_id(session['user_name'])[0]['id'])

    question = data_manager.filter_by_id('quest', question_id)[0]
    question['comments'] = data_manager.filter_by_id('comm', question_id)
    if 'user_name' in session:
        user_id = data_manager.get_user_id(session['user_name'])[0]['id']
        return render_template("new-question-comment.html",
                               question=question,
                               email=session['user_name'],
                               user_id=user_id)
    return redirect(url_for('login'))
예제 #5
0
def new_question_comment(question_id):
    if session.get(FORM_USERNAME):
        if request.method == "POST":
            details = dict(request.form)
            details["submission_time"] = util.get_current_date_time()
            if session.get(FORM_USERNAME):
                details["user_id"] = session['user_id']
            data_manager.add_question_comment(details)

            return redirect(
                url_for("display_question", question_id=question_id))
        if request.method == "GET":
            question = data_manager.get_question_by_id(question_id)
            response = make_response(
                render_template("add_comment.html",
                                username=SESSION_USERNAME,
                                item=question,
                                item_type="question",
                                url=url_for('new_question_comment',
                                            question_id=question_id)))
            # item_id = 'question_id'))
            return response
    else:
        return redirect(url_for('login_user'))