def add_photo_tag(req): r = { 'result':False } photo_id = req.get_form_var('image_id', None) photo = photo_id and EventPhoto.get(photo_id) if photo and req.user: left = req.get_form_var('left', None) top = req.get_form_var('top', None) width = req.get_form_var('width', None) height = req.get_form_var('height', None) name = req.get_form_var('name', None) uid = req.get_form_var('name_id', None) if name and not uid: user_dict = get_users_dict() uid = user_dict.get(name.cstrip().lower(), None) if uid: card = Card.get(uid) if card: tid = PhotoTag.new(photo_id, card.id, req.user.id, left, top, width, height) tag = PhotoTag.get(tid) if tag: r = { "result":True, "tag": tag.json_dict(req.user) } return json.dumps(r)