Пример #1
0
 def getCWFriends(self):
     query = Friends.gql('WHERE user_id1 = :1', self.user.user_id)
     friend_ids = [friend.user_id2 for friend in query]
     CW_friends = []
     for uid in friend_ids:
         f = User.get_by_key_name(uid)
         CW_friends.append(f)
     return CW_friends
Пример #2
0
def rule_sn_award(user):
    friend_num = Friends.gql('WHERE user_id1 = :1', user.user_id).count()
    gmp = get_user_gmp(user.user_id)
    gmp.current_points += (friend_num * FRIEND_POINTS - gmp.sn_points)
    gmp.sn_points = friend_num * FRIEND_POINTS
    gmp.total_points = gmp.sn_points + gmp.rating_points + gmp.action_points
    update_user_gmp_cache(user.user_id, gmp)
    gmp.put()
Пример #3
0
def rule_sn_award(user):
    friend_num = Friends.gql('WHERE user_id1 = :1', user.user_id).count()
    gmp = get_user_gmp(user.user_id)
    gmp.current_points += (friend_num * FRIEND_POINTS - gmp.sn_points)
    gmp.sn_points = friend_num * FRIEND_POINTS
    gmp.total_points = gmp.sn_points + gmp.rating_points + gmp.action_points
    update_user_gmp_cache(user.user_id, gmp)
    gmp.put()
Пример #4
0
 def getCWFriends(self):
     query = Friends.gql('WHERE user_id1 = :1', self.user.user_id)
     friend_ids = [friend.user_id2 for friend in query]
     CW_friends = []
     for uid in friend_ids:
         f = User.get_by_key_name(uid)
         CW_friends.append(f)
     return CW_friends
Пример #5
0
 def get(self):
     uid = self.request.get('uid')
     pending = PendingRequest.gql('WHERE sender_id = :1 AND receiver_id = :2', uid, self.user.user_id).get()
     pending.delete()
     
     friends1 = Friends(user_id1 = uid,
                       user_id2 = self.user.user_id)
     friends1.put()
     friends2 = Friends(user_id1 = self.user.user_id,
                        user_id2 = uid)
     friends2.put()
Пример #6
0
 def get(self, id):
     m_user = User.gql('WHERE user_id = :1', id).get()
     query = Friends.gql('WHERE user_id2 = :1', id)
     follower_ids = [item.user_id1 for item in query]
     query = User.gql('WHERE user_id IN :1', follower_ids)
     followers = [item for item in query]
     self.render('user_followers.html',
                 followers=followers,
                 user=m_user,
                 is_friend=self.is_friend(id))
Пример #7
0
 def get(self, id):
     m_user = User.gql('WHERE user_id = :1', id).get()
     query = Friends.gql('WHERE user_id2 = :1', id)
     follower_ids = [item.user_id1 for item in query]
     query = User.gql('WHERE user_id IN :1', follower_ids)
     followers = [item for item in query]
     self.render('user_followers.html',
                 followers = followers,
                 user = m_user,
                 is_friend = self.is_friend(id))
Пример #8
0
 def get(self, id):
     m_user = User.gql('WHERE user_id = :1', id).get()
     query = Friends.gql('WHERE user_id1 = :1', id)
     friend_ids = [friend.user_id2 for friend in query]
     CW_friends = []
     for uid in friend_ids:
         f = User.get_by_key_name(uid)
         CW_friends.append(f)
     self.render('user_friends.html',
                 user=m_user,
                 CW_friends=CW_friends,
                 is_friend=self.is_friend(id))
Пример #9
0
 def get(self, id):
     m_user = User.gql('WHERE user_id = :1', id).get()
     query = Friends.gql('WHERE user_id1 = :1', id)
     friend_ids = [friend.user_id2 for friend in query]
     CW_friends = []
     for uid in friend_ids:
         f = User.get_by_key_name(uid)
         CW_friends.append(f)
     self.render('user_friends.html',
                 user = m_user,
                 CW_friends = CW_friends,
                 is_friend = self.is_friend(id))
Пример #10
0
def get_top_friends(self_id):
    query1 = GMPoints.all()
    query2 = Friends.gql('WHERE user_id1 = :1', self_id)
    friend_ids = [f.user_id2 for f in query2]
    top_friends = []
    num = 0
    for top in query1:
        if top.user_id in friend_ids:
            top_friends.append(top.user_id)
            num += 1
            if num >= TOP_NUM:
                break
    return top_friends
Пример #11
0
def get_top_friends(self_id):
    query1 = GMPoints.all()
    query2 = Friends.gql("WHERE user_id1 = :1", self_id)
    friend_ids = [f.user_id2 for f in query2]
    top_friends = []
    num = 0
    for top in query1:
        if top.user_id in friend_ids:
            top_friends.append(top.user_id)
            num += 1
            if num >= TOP_NUM:
                break
    return top_friends
Пример #12
0
 def add_following(self, uid):
     relationship = Friends.gql('WHERE user_id1 = :1 AND user_id2 = :2', self.user.user_id, uid).get()
     if not relationship:
         relationship = Friends(user_id1 = self.user.user_id,
                                user_id2 = uid)
         relationship.put()
Пример #13
0
def is_friend(id1, id2):
    result = Friends.gql('WHERE user_id1 = :1 AND user_id2 = :2', id1,
                         id2).get()
    if result:
        return True
    return False
Пример #14
0
 def cancel_following(self, uid):
     relationship = Friends.gql('WHERE user_id1 = :1 AND user_id2 = :2', self.user.user_id, uid).get()
     if relationship:
         relationship.delete()
Пример #15
0
 def cancel_following(self, uid):
     relationship = Friends.gql('WHERE user_id1 = :1 AND user_id2 = :2',
                                self.user.user_id, uid).get()
     if relationship:
         relationship.delete()
Пример #16
0
 def add_following(self, uid):
     relationship = Friends.gql('WHERE user_id1 = :1 AND user_id2 = :2',
                                self.user.user_id, uid).get()
     if not relationship:
         relationship = Friends(user_id1=self.user.user_id, user_id2=uid)
         relationship.put()
Пример #17
0
def is_friend(id1, id2):
    result = Friends.gql("WHERE user_id1 = :1 AND user_id2 = :2", id1, id2).get()
    if result:
        return True
    return False