def get(self): user = self.user_model requests = ConnectionRequest.query( ConnectionRequest.requestee == user.username).order( -ConnectionRequest.time) self.response.out.write( template.render('views/requests.html', { 'viewer': user, 'requests': requests }))
def post(self): requestor = User.query(User.username == cgi.escape(self.request.get('requestor'))).get() requestee = User.query(User.username == cgi.escape(self.request.get('requestee'))).get() connection_request = ConnectionRequest.query(ConnectionRequest.requestee == requestee.username).get() if requestee.key not in requestor.friends: requestor.friends.append(requestee.key) requestor.put() if requestor.key not in requestee.friends: requestee.friends.append(requestor.key) requestee.request_count -= 1 requestee.put() if connection_request != None: connection_request.key.delete() self.redirect('/connect')
def post(self): requestor = User.query( User.username == cgi.escape(self.request.get('requestor'))).get() requestee = User.query( User.username == cgi.escape(self.request.get('requestee'))).get() connection_request = ConnectionRequest.query( ConnectionRequest.requestee == requestee.username).get() if requestee.key not in requestor.friends: requestor.friends.append(requestee.key) requestor.put() if requestor.key not in requestee.friends: requestee.friends.append(requestor.key) requestee.request_count -= 1 requestee.put() if connection_request != None: connection_request.key.delete() self.redirect('/connect')
def post(self): requestor = self.user_model q = User.query(User.username == self.request.get('requestee')) text = cgi.escape(self.request.get('text')) requestee = q.get() #Querying datastore to check for open connection request incoming_query = ConnectionRequest.query( ConnectionRequest.requestor == requestee.username, ConnectionRequest.requestee == requestor.username) outgoing_query = ConnectionRequest.query( ConnectionRequest.requestor == requestor.username, ConnectionRequest.requestee == requestee.username) incoming_request = incoming_query.get() outgoing_request = outgoing_query.get() #don't create 2 connection requests between users if incoming_request == None and outgoing_request == None: connection_request = ConnectionRequest() connection_request.requestor = requestor.username connection_request.requestee = requestee.username connection_request.time = datetime.datetime.now( ) - datetime.timedelta(hours=7) #For PST connection_request.text = text connection_request.requestor_key = requestor.key connection_request.requestor_name = requestor.first_name + " " + requestor.last_name connection_request.put() requestee.request_count += 1 requestee.put() self.redirect('/')
def post(self): requestor = self.user_model q = User.query(User.username == self.request.get('requestee')) text = cgi.escape(self.request.get('text')) requestee = q.get() #Querying datastore to check for open connection request incoming_query = ConnectionRequest.query(ConnectionRequest.requestor == requestee.username, ConnectionRequest.requestee == requestor.username) outgoing_query = ConnectionRequest.query(ConnectionRequest.requestor == requestor.username, ConnectionRequest.requestee == requestee.username) incoming_request = incoming_query.get() outgoing_request = outgoing_query.get() #don't create 2 connection requests between users if incoming_request == None and outgoing_request == None: connection_request = ConnectionRequest() connection_request.requestor = requestor.username connection_request.requestee = requestee.username connection_request.time = datetime.datetime.now() - datetime.timedelta(hours=7) #For PST connection_request.text = text connection_request.requestor_key = requestor.key connection_request.requestor_name = requestor.first_name + " " + requestor.last_name connection_request.put() requestee.request_count += 1 requestee.put() self.redirect('/')
def get(self): user = self.user_model requests = ConnectionRequest.query(ConnectionRequest.requestee == user.username).order(-ConnectionRequest.time) self.response.out.write(template.render('views/requests.html', {'viewer': user, 'requests': requests}))