コード例 #1
0
ファイル: db_posts_funcs.py プロジェクト: Janyell/DBForum
def post_details(post_id, related):
    post_response = post_select(post_id)
    if post_response is None:
        raise Exception("post: post with id = " + post_id + " not found")
    if "user" in related:
        post_response["user"] = db_users_func.user_details(post_response["user"])
    if "thread" in related:
        post_response["thread"] = db_threads_funcs.thread_details(thread_id=post_response["thread"], related=[])
    if "forum" in related:
        post_response["forum"] = db_forums_funcs.forum_details(short_name=post_response["forum"], related=[])
    return post_response
コード例 #2
0
ファイル: views.py プロジェクト: Janyell/DBForum
def details(request):
    if request.method == "GET":
        request_data = return_GET_params(request)
        required_data = ["forum"]
        related = return_related(request_data)
        try:
            params_are_right(request=request_data,
                            required=required_data)
            forum = db_forums_funcs.forum_details(short_name=request_data["forum"],
                                                  related=related)
        except Exception as e:
            return return_error(e.message)
        return return_response(forum)
    else:
        return HttpResponse(status=400)
コード例 #3
0
ファイル: db_threads_funcs.py プロジェクト: Janyell/DBForum
def thread_details(thread_id, related):
    thread = db_funcs.db_select(
        'SELECT date, forum, id, isClosed, isDeleted, message, slug, title, user, dislikes, likes, points, posts'
        ' FROM Threads'
        ' WHERE id = %s',
        (thread_id, )
    )
    if not len(thread):
        raise Exception('thread: thread with id=' + str(thread_id) + " not found")
    thread_response = thread_describe(thread[0])
    if "user" in related:
        thread_response["user"] = db_users_func.user_details(thread_response["user"])
    if "forum" in related:
        thread_response["forum"] = db_forums_funcs.forum_details(short_name=thread_response["forum"], related=[])
    return thread_response