def get(self): if self.user: uid = self.request.get('uid') pending = PendingRequest(sender_id = self.user.user_id, receiver_id = uid) pending.put() else: self.redirect('/')
def get(self): query = PendingRequest.gql('WHERE receiver_id = :1', self.user.user_id) pending_uids = [item.sender_id for item in query] query = User.gql('WHERE user_id IN :1', pending_uids) #IN may have a problem exceeding 30 reqs = [user for user in query] self.render('friendrequest.html', reqs = reqs)
def is_friend(self, uid): query1 = db.GqlQuery('SELECT user_id2 FROM Friends WHERE user_id1 = :1', self.user.user_id) friends = [friend.user_id2 for friend in query1] query2 = PendingRequest.gql('WHERE sender_id = :1', self.user.user_id) pending_uids = [item.receiver_id for item in query2] is_friend = -1 if uid in pending_uids: is_friend = 0 if uid in friends: is_friend = 1 return is_friend
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()
def is_friend(self, uid): query1 = db.GqlQuery( 'SELECT user_id2 FROM Friends WHERE user_id1 = :1', self.user.user_id) friends = [friend.user_id2 for friend in query1] query2 = PendingRequest.gql('WHERE sender_id = :1', self.user.user_id) pending_uids = [item.receiver_id for item in query2] is_friend = -1 if uid in pending_uids: is_friend = 0 if uid in friends: is_friend = 1 return is_friend
def search_user(self, keyword): keyword = keyword.lower() query1 = db.GqlQuery('SELECT user_id2 FROM Friends WHERE user_id1 = :1', self.user.user_id) friends = [friend.user_id2 for friend in query1] query2 = PendingRequest.gql('WHERE sender_id = :1', self.user.user_id) pending_uids = [item.receiver_id for item in query2] query3 = User.all() results = [] for tmpuser in query3: if tmpuser.user_id == self.user.user_id: continue if tmpuser.realname.lower().find(keyword) < 0: continue is_friend = -1 if tmpuser.user_id in pending_uids: is_friend = 0 if tmpuser.user_id in friends: is_friend = 1 results.append({'user':tmpuser, 'is_friend':is_friend}) return results
def search_user(self, keyword): keyword = keyword.lower() query1 = db.GqlQuery( 'SELECT user_id2 FROM Friends WHERE user_id1 = :1', self.user.user_id) friends = [friend.user_id2 for friend in query1] query2 = PendingRequest.gql('WHERE sender_id = :1', self.user.user_id) pending_uids = [item.receiver_id for item in query2] query3 = User.all() results = [] for tmpuser in query3: if tmpuser.user_id == self.user.user_id: continue if tmpuser.realname.lower().find(keyword) < 0: continue is_friend = -1 if tmpuser.user_id in pending_uids: is_friend = 0 if tmpuser.user_id in friends: is_friend = 1 results.append({'user': tmpuser, 'is_friend': is_friend}) return results
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()
def get_friendreq_num(uid): reqs = PendingRequest.gql('WHERE receiver_id = :1', uid) return reqs.count()
def get_friendreq_num(uid): reqs = PendingRequest.gql("WHERE receiver_id = :1", uid) return reqs.count()