Example #1
0
def list_threads(request):
    if request.method == "GET":
        request_data = return_GET_params(request)
        required_data = ["forum"]
        related = return_related(request_data)
        optional = return_optional(request=request_data, optional=["limit", "order", "since"])
        try:
            params_are_right(request=request_data,
                            required=required_data)
            threads_l = db_threads_funcs.thread_list(entity="forum",
                                                     entity_attr=request_data["forum"],
                                                     related=related,
                                                     params=optional)
        except Exception as e:
            return return_error(e.message)
        return return_response(threads_l)
    else:
        return HttpResponse(status=400)
Example #2
0
def thread_list(request):
    if request.method == "GET":
        request_data = return_GET_params(request)
        entity_attr = None
        try:
            entity_attr = request_data["forum"]
            entity = "forum"
        except KeyError:
            try:
                entity_attr = request_data["user"]
                entity = "user"
            except KeyError:
                return return_error("http: user or forum parameters not setted")
        optional = return_optional(request=request_data, optional=["limit", "order", "since"])
        try:
            t_list = db_threads_funcs.thread_list(entity=entity, entity_attr=entity_attr, related=[], params=optional)
        except Exception as e:
            return return_error(e.message)
        return return_response(t_list)
    else:
        return HttpResponse(status=400)