Beispiel #1
0
def detailsUser(request):
    if request.method == "GET":
        requestData = getParam(request)
        requiredData = ["user"]
        try:
            tryParam(input=requestData, required=requiredData)
            userdetails = UsersHelper.detailsHelper(email=requestData["user"])
        except Exception as e:
            return generateError(e.message)
        return getResponse(userdetails)
    else:
        return HttpResponse(status=400)
Beispiel #2
0
def listFollowing(request):
    if request.method == "GET":
        requestData = getParam(request)
        requiredData = ["user"]
        param = getOptional(request=requestData, values=["limit", "order", "since_id"])
        try:
            tryParam(input=requestData, required=requiredData)
            followings = listFollowersHelper(email=requestData["user"], fol1="followee", optional=param)
        except Exception as e:
            return generateError(e.message)
        return getResponse(followings)
    else:
        return HttpResponse(status=400)
Beispiel #3
0
def listPost(request):
    if request.method == "GET":
        requestData = getParam(request)
        requiredData = ["user"]
        option = getOptional(request=requestData, values=["limit", "order", "since"])
        try:
            tryParam(input=requestData, required=requiredData)
            arrayPosts = PostHelpers.postListHelper(table="user", id=requestData["user"], related=[], option=option)
        except Exception as e:
            return generateError(e.message)
        return getResponse(arrayPosts)
    else:
        return HttpResponse(status=400)
Beispiel #4
0
def listUsersForum(request):
    if request.method == "GET":
        request_data = getParam(request)
        required_data = ["forum"]
        optional = getOptional(request=request_data, values=["limit", "order", "since_id"])
        try:
            tryParam(input=request_data, required=required_data)
            arrayUsers = ForumsHelper.listForumUsersHelper(request_data["forum"], optional)
        except Exception as e:
            return generateError(e.message)
        return getResponse(arrayUsers)
    else:
        return HttpResponse(status=400)
Beispiel #5
0
def detailsThread(request):
    if request.method == "GET":
        requestData = getParam(request)
        requiredData = ["thread"]
        related = getRelated(requestData)
        try:
            tryParam(input=requestData, required=requiredData)
            threads = ThreadsHelper.detailsThreadHelper(id=requestData["thread"], related=related)
        except Exception as e:
            return generateError(e.message)
        return getResponse(threads)
    else:
        return HttpResponse(status=400)
Beispiel #6
0
def detailForum(request):
    if request.method == "GET":
        requestData = getParam(request)
        requiredData = ["forum"]
        related = getRelated(requestData)
        try:
            tryParam(input=requestData, required=requiredData)
            forums = ForumsHelper.detailForumHelper(short_name=requestData["forum"], related=related)
        except Exception as e:
            return generateError(e.message)
        return getResponse(forums)
    else:
        return HttpResponse(status=400)
Beispiel #7
0
def detailsPost(request):
    if request.method == "GET":

        requestData = getParam(request)
        requiredData = ["post"]
        relating = getRelated(requestData)
        try:
            tryParam(input=requestData, required=requiredData)
            posts = PostHelpers.detailsPostHelper(requestData["post"], option=relating)
        except Exception as e:
            return generateError(e.message)
        return getResponse(posts)
    else:
        return HttpResponse(status=400)
Beispiel #8
0
def listThreadsForum(request):
    if request.method == "GET":
        required = ["forum"]
        request = getParam(request)
        related = getRelated(request)
        optional = getOptional(request=request, values=["limit", "order", "since"])
        try:
            tryParam(input=request, required=required)
            arrayThreads = ThreadsHelper.listThreadHelper(table="forum", id=request["forum"],
                                             related=related, params=optional)
        except Exception as e:
            return generateError(e.message)
        return getResponse(arrayThreads)
    else:
        return HttpResponse(status=400)
Beispiel #9
0
def thread_list(request):
    if request.method == "GET":
        requestData = getParam(request)
        id = None
        try:
            id = requestData["forum"]
            table = "forum"
        except KeyError:
            try:
                id = requestData["user"]
                table = "user"
            except KeyError:
                return generateError("No user or forum parameters setted")
        optional = getOptional(request=requestData, values=["limit", "order", "since"])
        try:
            t_list = ThreadsHelper.listThreadHelper(table=table, id=id, related=[], params=optional)
        except Exception as e:
            return generateError(e.message)
        return getResponse(t_list)
    else:
        return HttpResponse(status=400)
Beispiel #10
0
def listPost(request):
    if request.method == "GET":
        requestData = getParam(request)
        id = None
        try:
            id = requestData["forum"]
            table = "forum"
        except KeyError:
            try:
                id = requestData["thread"]
                table = "thread"
            except KeyError:
                return generateError("ListPost Error")

        optional = getOptional(request=requestData, values=["limit", "order", "since"])
        try:
            postArray = PostHelpers.postListHelper(table=table, id=id, related=[], option=optional)
        except Exception as e:
            return generateError(e.message)
        return getResponse(postArray)
    else:
        return HttpResponse(status=400)