def deleteSessionInWishlist(self, request): """Delete sessions in users wishlist.""" user = endpoints.get_current_user() if not user: raise endpoints.UnauthorizedException('Authorization required') user_id = getUserId(user) # item = WishList.query(ndb.Key(urlsafe=request.sessionKey)) # item.delete() # key = ndb.Key(urlsafe=request.data) # print key # print "I just used the key" testQ = WishList.query() filtered = testQ.filter(WishList.sessionKey == request.data) # print filtered # p = testQ.filter(WishList.sessionKey == request.data and WishList.userID == user_id) for t in filtered: t.key.delete() websafeKey = StringMessage() # Fedback to user, confirming item in wishlist was deleted. websafeKey.data = "wishlist item deleted" return websafeKey
def addSessionToWishlist(self, request): """Adds conference to users wishlist.""" user = endpoints.get_current_user() if not user: raise endpoints.UnauthorizedException('Authorization required') user_id = getUserId(user) p_key = ndb.Key(urlsafe=request.sessionKey) print p_key wishItem = WishList(parent=p_key) #Assign the wishlist item to have both a sessionkey to get he session and the user_id to correctly call it #back uniquely to that user. wishItem.sessionKey = request.sessionKey wishItem.userID = user_id wishItem.put() # This is just setting up the message to return to the user websafeKey = StringMessage() websafeKey.data = "Successfully added to wishlist: " + request.sessionKey testQ = WishList.query() #Just return the message confirming that the session was added to the wishlist return websafeKey