Esempio n. 1
0
def details(request):
    if request.method == "GET":
        get_params = request.GET.dict()
        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 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)
Esempio n. 2
0
def details(request):
    if request.method == "GET":
        content = request.GET.dict()
        required_data = ["thread"]
        related = related_exists(content)
        try:
            choose_required(data=content, required=required_data)
            thread = threads.details(id=content["thread"], 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": thread}), content_type='application/json')
    else:
        return HttpResponse(status=405)
Esempio n. 3
0
def list_threads(request):
    if request.method == "GET":
        content = request.GET.dict()
        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.threads_list(entity="forum", identifier=content["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)