Ejemplo n.º 1
0
def list_posts(request):
    if request.method == "GET":
        request_info = GET_parameters(request)
        required_info = ["user"]
        opt = get_opt(request_info=request_info, possible_values=["limit", "order", "since"])
        try:
            test_require(data=request_info, required=required_info)
            posts_array = posts.posts_list(table_="user", parametr=request_info["user"], related=[], params=opt)
        except Exception as e:
            return return_error(e.message)
        return return_response(posts_array)
    else:
        return HttpResponse(status=400)
Ejemplo n.º 2
0
def post_list(request):
    if request.method == "GET":
        request_info = GET_parameters(request)
        param = None
        try:
            param = request_info["forum"]
            table_name = "forum"
        except KeyError:
            try:
                param = request_info["thread"]
                table_name = "thread"
            except KeyError:
                return return_error("No thread or forum parameters in request")

        opt = get_opt(request_info=request_info, possible_values=["limit", "order", "since"])
        try:
            post_array = posts.posts_list(table_=table_name, parametr=param, related=[], params=opt)
        except Exception as e:
            return return_error(e.message)
        return return_response(post_array)
    else:
        return HttpResponse(status=400)