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)
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)
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)
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)