Example #1
0
def add_question():
    if request.method == 'POST':
        message = request.form['message']
        title = request.form['title']
        if 'username' in session:
            data_manager.write_to_questions(
                message, title, util.get_username_id(session['username']))
        else:
            data_manager.write_to_questions(message, title)
        question_id = data_manager.generate_id()
        return redirect(url_for('show_questions', question_id=question_id))
    return render_template('add-question.html')
Example #2
0
def route_add_answer(question_id):
    if request.method == 'POST':
        new_answer = {
            'id': data_manager.generate_id(file=data_manager.answer),
            'submission_time': data_manager.get_time(),
            'vote_number': None,
            'question_id': question_id,
            'message': request.form.get('message'),
            'image': None
        }
        data_manager.add_message(new_answer, file=data_manager.answer)
        return redirect(url_for('route_answer', answer_id=new_answer['id']))
    return render_template('edit_answer.html', question_id=question_id)
Example #3
0
def post_new_answer(question_id):
    new_id = data_manager.generate_id("answers")
    now = datetime.now()
    x = datetime.timestamp(now)
    if request.method == 'POST':
        new_answer = {
            "id": new_id,
            "submission_time": int(x),  # de modificat timestamp
            "vote_number": str(0),
            "question_id": question_id,
            "message": request.form.get("message"),
            "image": request.form.get('image')}
        data_manager.write_data(new_answer, "answers")
        return redirect('/question/'+str(question_id))
    return render_template('new_answer.html', id=question_id)
Example #4
0
def route_add_question():
    if request.method == 'POST':
        new_question = {
            'title': request.form.get('title'),
            'message': request.form.get('message'),
            'submission_time': data_manager.get_time(),
            'id': data_manager.generate_id(),
            'view_number': None,
            'vote_number': None,
            'image': None
        }
        data_manager.add_message(new_question)
        return redirect('/list')
    return render_template('edit_question.html',
                           title_field='',
                           message_field='',
                           specific_url=url_for('route_add_question'))
Example #5
0
def add_question():
    new_id = data_manager.generate_id('questions')
    now = datetime.now()
    x= datetime.timestamp(now)

    if request.method == 'POST':
        question = {
            "id": new_id,
            "submission_time": int(x),  # de modificat timestamp
            "view_number": 0,
            "vote_number": 0,
            "title": request.form.get('title'),
            "message": request.form.get("message"),
            "image": request.form.get("image")
        }
        data_manager.write_data(question, 'questions')
        return redirect("/list")
    return render_template("add_question.html")