Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def detailsPostHelper(id, option):
    post = postQueryHelper(id)
    if post is None:
        raise Exception("no post with id = "+id)

    if "user" in option:
        post["user"] = UsersHelper.detailsHelper(post["user"])
    if "forum" in option:
        post["forum"] = ForumsHelper.detailForumHelper(short_name=post["forum"], related=[])
    if "thread" in option:
        post["thread"] = ThreadsHelper.detailsThreadHelper(id=post["thread"], related=[])

    return post
Ejemplo n.º 3
0
def detailsThreadHelper(id, related):
    select = Select(
        'select date, forum, id, isClosed, isDeleted, message, slug, title, user, dislikes, likes, points, posts '
        'FROM Threads WHERE id = %s', (id, )
    )
    if len(select) == 0:
        raise Exception('No thread exists with id=' + str(id))
    select = threadFormat(select)

    if "user" in related:
        select["user"] = UsersHelper.detailsHelper(select["user"])
    if "forum" in related:
        select["forum"] = ForumsHelper.detailForumHelper(short_name=select["forum"], related=[])

    return select