示例#1
0
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}
    )
示例#2
0
文件: post.py 项目: dm-tyurin/tp-subd
    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
示例#3
0
    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