Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def names(req):
    q = req.get_form_var('term', None)
    q = q.strip()
    r = []
    if q:
        user_dict = get_users_dict()
        ids = set([v for k, v in user_dict.iteritems() if k.startswith(q)])
        for i in list(ids):
            card = Card.get(i)
            r.append({ "id": card.id, "label":card.screen_name , "value": card.uid})
    return json.dumps(r)