Example #1
0
    def testBuildNewestLink(self):
        """
        Assert that build_newest_comment_link parses comment links and builds
        the new location correctly.
        """

        links = [{
            "rel": "self",
            "href": "/api/v1/conversations/161991?comment_id=7050281",
            "title": "1"
        }, {
            "rel": "next",
            "href":
            "/api/v1/conversations/161991?comment_id=7050281&offset=25",
            "title": "2"
        }, {
            "rel": "last",
            "href":
            "/api/v1/conversations/161991?comment_id=7050281&offset=875",
            "title": "36"
        }]
        response = {"comments": {"links": links}}

        location = build_newest_comment_link(response)
        assert location == '/conversations/161991/#comment7050281'
Example #2
0
def newest(request, huddle_id):
    """
    Get redirected to the first unread post in a huddle
    """

    try:
        response = Huddle.newest(request.get_host(), huddle_id, access_token=request.access_token)
    except APIException as exc:
        return respond_with_error(request, exc)

    redirect = build_newest_comment_link(response)
    return HttpResponseRedirect(redirect)
Example #3
0
def newest(request, conversation_id):
    """
    Redirect to the user's first unread post in the conversation.
    """

    try:
        response = Conversation.newest(request.get_host(), conversation_id, access_token=request.access_token)
    except APIException as exc:
        return respond_with_error(request, exc)

    redirect = build_newest_comment_link(response, request)
    return HttpResponseRedirect(redirect)
Example #4
0
def incontext(request, comment_id):
    """
    Redirect to the user's first unread comment in a list of comments.
    """

    try:
        response = Comment.incontext(request.get_host(), comment_id, access_token=request.access_token)
    except APIException as exc:
        return respond_with_error(request, exc)

    redirect = build_newest_comment_link(response, request)
    return HttpResponseRedirect(redirect)
Example #5
0
def newest(request, huddle_id):
    """
    Get redirected to the first unread post in a huddle
    """

    try:
        response = Huddle.newest(request.get_host(), huddle_id, access_token=request.access_token)
    except APIException as exc:
        return respond_with_error(request, exc)

    redirect = build_newest_comment_link(response, request)
    return HttpResponseRedirect(redirect)
Example #6
0
def incontext(request, comment_id):
    """
    Redirect to the user's first unread comment in a list of comments.
    """

    try:
        response = Comment.incontext(request.get_host(),
                                     comment_id,
                                     access_token=request.access_token)
    except APIException as exc:
        return respond_with_error(request, exc)

    redirect = build_newest_comment_link(response, request)
    return HttpResponseRedirect(redirect)
Example #7
0
def newest(request, conversation_id):
    """
    Redirect to the user's first unread post in the conversation.
    """

    try:
        response = Conversation.newest(request.get_host(),
                                       conversation_id,
                                       access_token=request.access_token)
    except APIException as exc:
        return respond_with_error(request, exc)

    redirect = build_newest_comment_link(response, request)
    return HttpResponseRedirect(redirect)
Example #8
0
    def testBuildNewestLink(self):
        """
        Assert that build_newest_comment_link parses comment links and builds
        the new location correctly.
        """

        links = [
            {"rel": "self", "href": "/api/v1/conversations/161991?comment_id=7050281", "title": "1"},
            {"rel": "next", "href": "/api/v1/conversations/161991?comment_id=7050281&offset=25", "title": "2"},
            {"rel": "last", "href": "/api/v1/conversations/161991?comment_id=7050281&offset=875", "title": "36"},
        ]
        response = {"comments": {"links": links}}

        location = build_newest_comment_link(response)
        assert location == "/conversations/161991/#comment7050281"