Esempio n. 1
0
def edit(_id, message, image=None):
    item = get(_id)
    item['message'] = message
    item['image'] = image
    DB_answer.edit(item)
    item['message'] = message
    DB_answer.edit(item)
Esempio n. 2
0
def add(form, question_id: str, image=None):
    answer = {
        'id': get_new_id(),
        'submission_time': utils.date_generator(),
        'message': form['message'],
        'question_id': question_id,
        'vote_number': 0,
        'image': form['image']
    }

    DB_answer.add(
        answer)  # put an empty line between variables declaration and methods
def search(data: str):
    questions_found = []
    questions = (DB_question.search_by_text(data))
    for i in questions:
        questions_found.append(i)
    answers = DB_answer.search_by_text(data)
    for i in answers:
        answer_id = i['id']
        questions_found.append(get(answer_id))

    return questions_found
Esempio n. 4
0
def get_new_id():
    return DB_answer.get_last_id() + 1
Esempio n. 5
0
def delete(_id):
    DB_answer.delete(_id)
Esempio n. 6
0
def get_by_question_with_comments(question_id):
    return DB_answer.get_by_question_with_comments(question_id)
Esempio n. 7
0
def get_by_question(question_id: str):
    return DB_answer.get_by_question_id(question_id)
Esempio n. 8
0
def get(_id):
    return DB_answer.get_by_id(_id)[0]