def put(group_id):
try:
args = put_parser.parse_args()
except BadRequest:
return abort(400, message="Invalid arguments")
with db:
with db.cursor() as cursor:
user_id = id_from_token(args['token'])
if user_id is None:
return abort(403, message="Token is not allowed to view this group")
cursor.execute("SELECT id FROM groups_rel WHERE user_id=%s AND groups_rel.group_id=%s",
[user_id, group_id])
group = cursor.fetchone()
if group is None:
return abort(403, message="Token is not allowed to view this group")
cursor.execute("INSERT INTO group_recipe_vote_log (grecipe_id, user_id, action) VALUES "
"((SELECT id FROM group_recipes WHERE group_id=%s AND group_recipes.recipe_id=%s),"
" %s, %s)",
[group_id, args['recipe_id'], user_id, args['action']])
return None, 200
评论列表
文章目录