Exemple #1
0
def details():
    get_params = get_json(request)
    required_data = ["forum"]
    related = related_exists(get_params)
    try:
        choose_required(data=get_params, required=required_data)
        forum = forums.details(short_name=get_params["forum"], related=related)
    except Exception as e:
        return json.dumps({"code": 1, "response": (e.message)})
    return json.dumps({"code": 0, "response": forum})
Exemple #2
0
def details():
    content = get_json(request)
    required_data = ["post"]
    related = related_exists(content)
    try:
        choose_required(data=content, required=required_data)
        post = posts.details(content["post"], related=related)
    except Exception as e:
        return json.dumps({"code": 1, "response": (e.message)})
    return json.dumps({"code": 0, "response": post})
Exemple #3
0
def list_threads():
    content = get_json(request)
    required_data = ["forum"]
    related = related_exists(content)
    optional = intersection(request=content, values=["limit", "order", "since"])
    try:
        choose_required(data=content, required=required_data)
        threads_l = threads.thread_list(entity="forum", identifier=content["forum"],
                                         related=related, params=optional)
    except Exception as e:
        return json.dumps({"code": 1, "response": (e.message)})
    return json.dumps({"code": 0, "response": threads_l})
Exemple #4
0
def details():
    content = get_json(request)
    required_data = ["thread"]
    related = related_exists(content)
    if 'thread' in related:
        return json.dumps({"code": 3, "response": "error"})
    try:
        choose_required(data=content, required=required_data)
        thread = threads.details(id=content["thread"], related=related)
    except Exception as e:
        return json.dumps({"code": 1, "response": (e.message)})
    return json.dumps({"code": 0, "response": thread})
Exemple #5
0
def list_posts():
    content = get_json(request)
    required_data = ["forum"]
    print content
    related = related_exists(content)
    print related

    optional = intersection(request=content, values=["limit", "order", "since"])
    #try:
    choose_required(data=content, required=required_data)
    posts_l = posts.posts_list(entity="forum", params=optional, identifier=content["forum"],
                                   related=related)
    #except Exception as e:
    #    print 'exeption /listPosts/'
    #    return json.dumps({"code": 1, "response": (e.message)})
    print ('correct /listPosts/')
    return json.dumps({"code": 0, "response": posts_l})
Exemple #6
0
def details():
    content = get_json(request)
    required_data = ["thread"]
    related = related_exists(content)
    if 'thread' in related:
        return json.dumps({"code": 3, "response": "error"})
    try:
        choose_required(data=content, required=required_data)
        thread = threads.details(id=content["thread"], related=related)
        #print('thread is deleted')
        #print(thread['isDeleted'])
        #if thread['isDeleted'] == True:
        #    thread['posts'] = 0
        #    print(thread['posts'])
    except Exception as e:
        return json.dumps({"code": 1, "response": (e.message)})
    return json.dumps({"code": 0, "response": thread})