예제 #1
0
파일: posts.py 프로젝트: Taniy/DBForum
def details(id, related):
    post = posts_query(id)
    if post is None:
        raise Exception("no post with id = "+id)
    if "user" in related:
        post["user"] = users.details(post["user"])
    if "forum" in related:
        post["forum"] = forums.details(short_name=post["forum"], related=[])
    if "thread" in related:
        post["thread"] = threads.details(id=post["thread"], related=[])
    return post
예제 #2
0
파일: forum.py 프로젝트: Taniy/DBForum
def details(request):
    if request.method == "GET":
        request_info = GET_parameters(request)
        required_info = ["forum"]
        relate = get_relate(request_info)
        try:
            test_require(data=request_info, required=required_info)
            forum = forums.details(short_name=request_info["forum"], related=relate)
        except Exception as e:
            return return_error(e.message)
        return return_response(forum)
    else:
        return HttpResponse(status=400)
예제 #3
0
파일: threads.py 프로젝트: Taniy/DBForum
def details(id, related):
    thread = selectQuery(
        'select date, forum, id, isClosed, isDeleted, message, slug, title, user, dislikes, likes, points, posts '
        'FROM Threads WHERE id = %s', (id, )
    )
    if len(thread) == 0:
        raise Exception('No thread exists with id=' + str(id))
    thread = threads_info(thread)

    if "user" in related:
        thread["user"] = users.details(thread["user"])
    if "forum" in related:
        thread["forum"] = forums.details(short_name=thread["forum"], related=[])
    return thread