def post(self, gameid): user = auth() if user == None: self.response.out.write(json.dumps({'error': 'No autheticated user'})) return gameid = int(gameid) text = self.request.get("text") bitmap = self.request.get("image") message = MyMessage() message.time = datetime.datetime.now() message.user = user message.gameid = gameid message.img = bitmap message.text = text message.confirmed = False message.put() self.response.out.write(json.dumps({'success': 'sent message'}))
def post(self, messageid): user = auth() if user == None: self.response.out.write(json.dumps({'error': 'No autheticated user'})) return confirm = self.request.get("confirm"); message = MyMessage.get_by_id(int(messageid)) if confirm == "true": message.confirmed = True else: message.confirmed = False message.put()
def post(self): logging.debug("CreateGame: ") user = auth() if user == None: logging.debug("CreateGame: Entered unauthenticated user!!") self.response.out.write(json.dumps({'error': 'Unauthenticated User'})) return #sendMessage(user, "HELLO"); logging.debug("CreateGame: Before creating Game Object") #Create Game game = Game() game.name = self.request.get("name") game.players = [] game.messages = [] game.creator = user.key().id() game.location = user.location game.range = float(self.request.get('range')) game.startTime = datetime.datetime.now() logging.debug("CreateGame: Before creating Clue Object") clue = MyMessage() clue.text = self.request.get('clue') clue.time = datetime.datetime.now() clue.put() logging.debug("CreateGame: Clue Object Created") game.clue = clue.key().id() game.active = True game.put() logging.debug("Game object created") clue.gameid = game.key().id() clue.user = user clue.put() user.activeGame = game user.put() #Notify users in the location #Return Game ID to UI logging.debug(game.key().id()) self.response.out.write(json.dumps({'gameid': game.key().id()}))
def get(self, gameid, since): user = auth() if user == None: self.response.out.write(json.dumps({'error': 'No autheticated user'})) return logging.debug("here") since = int(since)/1000 logging.debug(gameid) q = MyMessage.gql("WHERE gameid = "+gameid) logging.debug(q.count()) results = q.fetch(20) reply = [] for result in results: if time.mktime(result.time.timetuple()) > since: reply.append(result.toDict()) logging.debug(reply) self.response.out.write(json.dumps(reply))