def thread_details(connect): cursor = connect.cursor(cursor_class=MySQLCursorDict) req_args = ['thread'] thread = extract_req(request.args, req_args) related = extract_list(request.args, 'related', ['user', 'forum']) thread = get_thread_by_id(cursor, thread) if 'user' in related: thread['user'] = get_user_by_email(cursor, thread['user']) if 'forum' in related: thread['forum'] = get_forum_by_slug(cursor, thread['forum']) cursor.close() return response_ok(thread)
def post_details(connect): cursor = connect.cursor(cursor_class=MySQLCursorDict) req_args = ['post'] post = extract_req(request.args, req_args) related = extract_list(request.args, 'related', ['user', 'forum', 'thread']) post = get_post_by_id(cursor, post) if 'user' in related: post['user'] = get_user_by_email(cursor, post['user']) if 'forum' in related: post['forum'] = get_forum_by_slug(cursor, post['forum']) if 'thread' in related: post['thread'] = get_thread_by_id(cursor, post['thread']) cursor.close() return response_ok(post)