예제 #1
0
def list_threads(request):
    if request.method == "GET":
        request_data = request.GET.dict()
        required_data = ["forum"]
        related = related_exists(request_data)
        optional = intersection(request=request_data,
                                values=["limit", "order", "since"])
        try:
            choose_required(data=request_data, required=required_data)
            threads_l = views.threads_list(entity="forum",
                                           identifier=request_data["forum"],
                                           related=related,
                                           params=optional)
        except Exception as e:
            return HttpResponse(json.dumps({
                "code": 1,
                "response": (e.message)
            }),
                                content_type='application/json')
        return HttpResponse(json.dumps({
            "code": 0,
            "response": threads_l
        }),
                            content_type='application/json')
    else:
        return HttpResponse(status=405)
예제 #2
0
def details(request):
    if request.method == "GET":
        request_data = request.GET.dict()
        required_data = ["forum"]
        related = related_exists(request_data)
        try:
            choose_required(data=request_data, required=required_data)
            forum = views.detail_forum(short_name=request_data["forum"], related=related)
        except Exception as e:
            return HttpResponse(json.dumps({"code": 1, "response": (e.message)}), content_type='application/json')
        return HttpResponse(json.dumps({"code": 0, "response": forum}), content_type='application/json')
    else:
        return HttpResponse(status=405)
예제 #3
0
def details(request):
    if request.method == "GET":

        request_data = request.GET.dict()
        required_data = ["post"]
        related = related_exists(request_data)
        try:
            choose_required(data=request_data, required=required_data)
            post = views.detail_post(request_data["post"], related=related)
        except Exception as e:
            return HttpResponse(json.dumps({"code": 1, "response": (e.message)}), content_type='application/json')
        return HttpResponse(json.dumps({"code": 0, "response": post}), content_type='application/json')
    else:
        return HttpResponse(status=405)
예제 #4
0
def list_threads(request):
    if request.method == "GET":
        request_data = request.GET.dict()
        required_data = ["forum"]
        related = related_exists(request_data)
        optional = intersection(request=request_data, values=["limit", "order", "since"])
        try:
            choose_required(data=request_data, required=required_data)
            threads_l = views.threads_list(entity="forum", identifier=request_data["forum"],
                                            related=related, params=optional)
        except Exception as e:
            return HttpResponse(json.dumps({"code": 1, "response": (e.message)}), content_type='application/json')
        return HttpResponse(json.dumps({"code": 0, "response": threads_l}), content_type='application/json')
    else:
        return HttpResponse(status=405)