Exemple #1
0
def add_post_to_favorites(ctx: rest.Context,
                          params: Dict[str, str]) -> rest.Response:
    auth.verify_privilege(ctx.user, 'posts:favorite')
    post = _get_post(params)
    favorites.set_favorite(post, ctx.user)
    ctx.session.commit()
    return _serialize_post(ctx, post)
Exemple #2
0
def add_post_to_favorites(
        ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
    auth.verify_privilege(ctx.user, 'posts:favorite')
    post = _get_post(params)
    favorites.set_favorite(post, ctx.user)
    ctx.session.commit()
    return _serialize_post(ctx, post)
Exemple #3
0
def add_post_to_favorites(ctx, params):
    auth.verify_privilege(ctx.user, 'posts:favorite')
    post = posts.get_post_by_id(params['post_id'])
    favorites.set_favorite(post, ctx.user)
    ctx.session.commit()
    return _serialize_post(ctx, post)
Exemple #4
0
 def post(self, ctx, post_id):
     auth.verify_privilege(ctx.user, 'posts:favorite')
     post = posts.get_post_by_id(post_id)
     favorites.set_favorite(post, ctx.user)
     ctx.session.commit()
     return posts.serialize_post_with_details(post, ctx.user)
Exemple #5
0
 def post(self, ctx, post_id):
     auth.verify_privilege(ctx.user, 'posts:favorite')
     post = posts.get_post_by_id(post_id)
     favorites.set_favorite(post, ctx.user)
     ctx.session.commit()
     return posts.serialize_post_with_details(post, ctx.user)