Example #1
0
def recommend(post_id, comment_id=None, text=None):
    try:
        try:
            posts.recommend(post_id, comment_id, text)
            return xmpp_template('recommendation_sent',
                                 post_id=post_id,
                                 comment_id=comment_id)
        except RecommendationExists:
            try:
                posts.unrecommend(post_id, comment_id)
                return xmpp_template('recommendation_cancel_sent',
                                     post_id=post_id,
                                     comment_id=comment_id)
            except RecommendationNotFound:
                pass
    except PostNotFound:
        return xmpp_template('post_not_found', post_id=post_id)
    except CommentNotFound:
        return xmpp_template('comment_not_found',
                             post_id=post_id,
                             comment_id=comment_id)
    except PostReadonlyError:
        return xmpp_template('post_readonly', post_id=post_id)
    except RecommendationError:
        return xmpp_template('post_recommend_denied', post_id=post_id)
    except PostAuthorError:
        return xmpp_template('post_denied', post_id=post_id)
Example #2
0
def unrecommend(id):
    comment_id = env.request.args('comment_id')
    try:
        posts.unrecommend(id, comment_id)
    except RecommendationNotFound:
        pass

    return Response(redirect=env.request.referer)
Example #3
0
def unrecommend(id):
    comment_id = env.request.args('comment_id')
    try:
        posts.unrecommend(id, comment_id)
    except RecommendationNotFound:
        pass

    return Response(redirect=env.request.referer)
Example #4
0
def recommend(post_id, comment_id=None, text=None):
    try:
        try:
            posts.recommend(post_id, comment_id, text)
            return xmpp_template('recommendation_sent',
                                  post_id=post_id, comment_id=comment_id)
        except RecommendationExists:
            try:
                posts.unrecommend(post_id, comment_id)
                return xmpp_template('recommendation_cancel_sent',
                                      post_id=post_id, comment_id=comment_id)
            except RecommendationNotFound:
                pass
    except PostNotFound:
        return xmpp_template('post_not_found', post_id=post_id)
    except CommentNotFound:
        return xmpp_template('comment_not_found', post_id=post_id,
                                                  comment_id=comment_id)
    except RecommendationError:
        return xmpp_template('post_recommend_denied', post_id=post_id)
    except PostAuthorError:
        return xmpp_template('post_denied', post_id=post_id)
Example #5
0
def unrecommend_comment(id, comment_id):
    posts.unrecommend(id, comment_id)
Example #6
0
def unrecommend_post(id):
    posts.unrecommend(id, None)
Example #7
0
def unrecommend_comment(id, comment_id):
    posts.unrecommend(id, comment_id)
Example #8
0
def unrecommend_post(id):
    posts.unrecommend(id, None)