Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #5
0
def unrecommend_comment(id, comment_id):
    posts.unrecommend(id, comment_id)
Пример #6
0
def unrecommend_post(id):
    posts.unrecommend(id, None)
Пример #7
0
def unrecommend_comment(id, comment_id):
    posts.unrecommend(id, comment_id)
Пример #8
0
def unrecommend_post(id):
    posts.unrecommend(id, None)