示例#1
0
def update_twitter_friends(user, info):
    twuser = TWFriends.gql('WHERE twitter_id = :1',
                           info.get('twitter_id')).get()
    if not twuser:
        twuser = TWFriends(twitter_id=info.get('twitter_id'))
    friends = info.get('friends')
    friends = set(friends)
    query = User.all()
    cw_tw_ids = [item.twitter_id for item in query]
    tw_on_cw = list(friends.intersection(cw_tw_ids))
    twuser.num_on_cw = len(tw_on_cw)

    friends.difference_update(tw_on_cw)
    realign_friends = list(tw_on_cw)
    realign_friends.extend(friends)
    twuser.friends = realign_friends
    twuser.put()

    for tw_id in tw_on_cw:
        tmpuser = User.gql('WHERE twitter_id = :1', tw_id).get()
        relation = Friends.gql('WHERE user_id1 = :1 AND user_id2 = :2',
                               user.user_id, tmpuser.user_id).get()
        if not relation:
            relation1 = Friends(user_id1=user.user_id,
                                user_id2=tmpuser.user_id)
            relation1.put()
            relation2 = Friends(user_id1=tmpuser.user_id,
                                user_id2=user.user_id)
            relation2.put()

    import gmp_rules
    gmp_rules.rule_sn_award(user)
示例#2
0
def update_twitter_friends(user, info):
    twuser = TWFriends.gql('WHERE twitter_id = :1', info.get('twitter_id')).get()
    if not twuser:
        twuser = TWFriends(twitter_id = info.get('twitter_id'))
    friends = info.get('friends')
    friends = set(friends)
    query = User.all()
    cw_tw_ids = [item.twitter_id for item in query]
    tw_on_cw = list(friends.intersection(cw_tw_ids))
    twuser.num_on_cw = len(tw_on_cw)
    
    friends.difference_update(tw_on_cw)
    realign_friends = list(tw_on_cw)
    realign_friends.extend(friends)
    twuser.friends = realign_friends
    twuser.put()
    
    for tw_id in tw_on_cw:
        tmpuser = User.gql('WHERE twitter_id = :1', tw_id).get()
        relation = Friends.gql('WHERE user_id1 = :1 AND user_id2 = :2', user.user_id, tmpuser.user_id).get()
        if not relation:
            relation1 = Friends(user_id1 = user.user_id,
                                user_id2 = tmpuser.user_id)
            relation1.put()
            relation2 = Friends(user_id1 = tmpuser.user_id,
                                user_id2 = user.user_id)
            relation2.put()
    
    import gmp_rules
    gmp_rules.rule_sn_award(user)
示例#3
0
def update_facebook_friends(user, info):
    fbuser = FBFriends.gql('WHERE facebook_id = :1',
                           info.get('facebook_id')).get()
    if not fbuser:
        fbuser = FBFriends(facebook_id=info.get('facebook_id'))
    friends = info.get('friends')
    friends = set(friends)
    query = User.all()
    cw_fb_ids = [item.facebook_id for item in query]
    fb_on_cw = list(friends.intersection(cw_fb_ids))
    fbuser.num_on_cw = len(fb_on_cw)

    friends.difference_update(fb_on_cw)
    realign_friends = list(fb_on_cw)
    realign_friends.extend(friends)
    fbuser.friends = realign_friends
    fbuser.put()

    for fb_id in fb_on_cw:
        tmpuser = User.gql('WHERE facebook_id = :1', fb_id).get()
        relation = Friends.gql('WHERE user_id1 = :1 AND user_id2 = :2',
                               user.user_id, tmpuser.user_id).get()
        if not relation:
            relation1 = Friends(user_id1=user.user_id,
                                user_id2=tmpuser.user_id)
            relation1.put()
            relation2 = Friends(user_id1=tmpuser.user_id,
                                user_id2=user.user_id)
            relation2.put()

    import gmp_rules
    gmp_rules.rule_sn_award(user)
示例#4
0
def update_facebook_friends(user, info):
    fbuser = FBFriends.gql('WHERE facebook_id = :1', info.get('facebook_id')).get()
    if not fbuser:
        fbuser = FBFriends(facebook_id = info.get('facebook_id'))
    friends = info.get('friends')
    friends = set(friends)
    query = User.all()
    cw_fb_ids = [item.facebook_id for item in query]
    fb_on_cw = list(friends.intersection(cw_fb_ids))
    fbuser.num_on_cw = len(fb_on_cw)
    
    friends.difference_update(fb_on_cw)
    realign_friends = list(fb_on_cw)
    realign_friends.extend(friends)
    fbuser.friends = realign_friends
    fbuser.put()
    
    for fb_id in fb_on_cw:
        tmpuser = User.gql('WHERE facebook_id = :1', fb_id).get()
        relation = Friends.gql('WHERE user_id1 = :1 AND user_id2 = :2', user.user_id, tmpuser.user_id).get()
        if not relation:
            relation1 = Friends(user_id1 = user.user_id,
                                user_id2 = tmpuser.user_id)
            relation1.put()
            relation2 = Friends(user_id1 = tmpuser.user_id,
                                user_id2 = user.user_id)
            relation2.put()
    
    import gmp_rules
    gmp_rules.rule_sn_award(user)