def details(): request_data = get_json(request) if 'related' in request_data: code, response = Forum.details(request_data['forum'], request_data['related']) else: code, response = Forum.details(request_data['forum']) return json.dumps( {'code': code, 'response': response} )
def details(post_id, related=None): if not related: related = [] code, result = Post.get_post(post_id) if code != Codes.OK: return code, result if code == Codes.OK and 'user' in related: code, result['user'] = User.details(result['user']) if code == Codes.OK and 'forum' in related: code, result['forum'] = Forum.details(result['forum']) if code == Codes.OK and 'thread' in related: code, result['thread'] = Thread.details(result['thread']) return code, result
def details(thread_id, related=None): if not related: related = [] if 'thread' in related: return Codes.NOT_CORRECT, 'Thread can\'t be in related' code, result = Thread.get_thread(thread_id) if code != Codes.OK: return code, result if code == Codes.OK and 'user' in related: code, result['user'] = User.details(result['user']) if code == Codes.OK and 'forum' in related: code, result['forum'] = Forum.details(result['forum'], None) return code, result