Beispiel #1
0
def delete_answer(answer_id, question_id):
    answer_table = common.get_table_from_file("data/answer.csv")
    for element in answer_table:
        if element[0] == answer_id:
            answer_table.remove(element)
    common.write_table_to_file(answer_table, "data/answer.csv")
    return redirect(url_for('answer', question_id=question_id))
Beispiel #2
0
def submit_question():
    if "SLY" in request.form["question_title"]:
        return render_template("sly.html")
    table = common.get_table_from_file("data/question.csv")
    submit_data_list = []
    VIEW_NUMBER = "0"
    VOTE_NUMBER = "0"
    filename = ""
    file = request.files['file']
    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
        file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
    ID = common.ID_generator(table)
    submit_data_list.append(ID)
    timestamp = datetime.datetime.fromtimestamp(
        time()).strftime('%Y-%m-%d %H:%M:%S')
    submit_data_list.append(timestamp)
    submit_data_list.append(VIEW_NUMBER)
    submit_data_list.append(VOTE_NUMBER)
    submit_data_list.append(request.form["question_title"])
    submit_data_list.append(request.form["message"])
    submit_data_list.append(filename)
    table.append(submit_data_list)
    common.write_table_to_file(table, "data/question.csv")
    return redirect(url_for("index"))
Beispiel #3
0
def update_data(question_id):
    question_table = common.get_table_from_file("data/question.csv")
    updated_question = []
    filename = None
    if 'file' in request.files:
        file = request.files['file']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
    for element in question_table:
        if element[0] == question_id:
            updated_question.append(element)
            question_table.remove(element)
    flatten_updated_question = []
    for element in updated_question:
        for item in element:
            flatten_updated_question.append(item)
    flatten_updated_question.pop(4)
    flatten_updated_question.pop(4)
    flatten_updated_question.insert(4, request.form['updated-question_title'])
    flatten_updated_question.insert(5, request.form['updated-message'])
    if filename is not None:
        flatten_updated_question.insert(6, filename)
    question_table.append(flatten_updated_question)
    common.write_table_to_file(question_table, "data/question.csv")
    return redirect(url_for('answer', question_id=question_id))
Beispiel #4
0
def view_func(question_id):
    question_table = common.get_table_from_file("data/question.csv")
    for element in question_table:
        if element[0] == question_id:
            views = int(element[2]) + 1
            question_table[question_table.index(element)][2] = str(views)
            common.write_table_to_file(question_table, "data/question.csv")
    return redirect(url_for('answer', question_id=question_id))
def delete_data():
    table = common.get_table_from_file()
    ID = request.form['delete']
    ID_string = str(ID)
    for element in table:
        if element[0] == ID_string:
            table.remove(element)
    common.write_table_to_file(table)
    return redirect(url_for('home_list'))
def read_and_add_form_data():
    table = common.get_table_from_file()
    data_list = []
    data_list.insert(0, common.ID_generator(table))
    request_names = [
        'story-title', 'user-story', 'accept-crit', 'bussines-value',
        'estimation', 'status'
    ]
    for name in request_names:
        data_list.append(request.form[name])
    cleared_data_list = common.clear_input(data_list)
    table.append(cleared_data_list)
    common.write_table_to_file(table)
Beispiel #7
0
def submit_answer(question_id):
    answers = common.get_table_from_file("data/answer.csv")
    new_answer = []
    timestamp = datetime.datetime.fromtimestamp(
        time()).strftime('%Y-%m-%d %H:%M:%S')
    new_answer.append(common.ID_generator(answers))
    new_answer.append(timestamp)
    new_answer.append("0")
    new_answer.append(question_id)
    new_answer.append(request.form["answer"])
    new_answer.append("IMAGE")
    answers.append(new_answer)
    common.write_table_to_file(answers, "data/answer.csv")
    return redirect(url_for('answer', question_id=question_id))
Beispiel #8
0
def delete_question(question_id):
    question_table = common.get_table_from_file("data/question.csv")
    answer_table = common.get_table_from_file("data/answer.csv")
    ID_INDEX = 0
    for element in question_table:
        if element[ID_INDEX] == question_id:
            question_table.remove(element)
    temp_table = []
    for question_id_old in answer_table:
        if question_id_old[3] != question_id:
            temp_table.append(question_id_old)
    common.write_table_to_file(question_table, "data/question.csv")
    common.write_table_to_file(temp_table, "data/answer.csv")
    return redirect(url_for("index"))
Beispiel #9
0
def route_save_story():
    table = common.get_table_from_file('data.csv')
    if request.method == 'POST':
        story_title = request.form['story_title']
        user_story = request.form['user_story']
        acceptance_criteria = request.form['acceptance_criteria']
        business_value = str(request.form['business_value']) + ' points'
        estimation = str(request.form['estimation']) + ' h'
        new_id = str(int(table[-1][0]) + 1)
        new_story_list = [
            new_id, story_title, user_story, acceptance_criteria,
            business_value, estimation, 'planning'
        ]
        table.append(new_story_list)
        common.write_table_to_file('data.csv', table)
    return redirect('/')
def edit_story():
    table = common.get_table_from_file()
    ID = request.form["edit"]
    ID_string = str(ID)
    changed_story = []
    changed_story.append(ID_string)
    request_names = [
        'changed-story-title', 'changed-user-story', 'changed-accept-crit',
        'changed-bussines-value', 'changed-estimation', 'changed-status'
    ]
    for names in request_names:
        changed_story.append(request.form[names])
    cleared_data_list = common.clear_input(changed_story)
    for element in table:
        if element[0] == ID_string:
            table.remove(element)
            table.insert(0, cleared_data_list)
    common.write_table_to_file(table)
    return redirect(url_for('home_list'))
Beispiel #11
0
def route_save_updated_story(story_id):
    table = common.get_table_from_file('data.csv')
    if request.method == 'POST':
        story_title = request.form['story_title']
        user_story = request.form['user_story']
        acceptance_criteria = request.form['acceptance_criteria']
        business_value = str(request.form['business_value']) + ' points'
        estimation = str(request.form['estimation']) + ' h'
        status = request.form['status']
        for line in table:
            if line[0] == str(story_id):
                line.clear()
                updated_story_list = [
                    story_id, story_title, user_story, acceptance_criteria,
                    business_value, estimation, status
                ]
                for i in updated_story_list:
                    line.append(i)
                common.write_table_to_file('data.csv', table)
                return redirect('/')