def post(self): privateKey = cgi.escape(self.request.get('privateKey')) profile = Profile.all().filter("privateKey =", privateKey).get() # should do nothing and tell no error, to avoid ppl searching for private keys? if(not profile): self.response.set_status(500, message="Can't find profile with key " + privateKey) return if (not profile.guest): self.response.set_status(500, message="Can't change an already registered profile when it is not guest") return profile.guest = False profile.name = cgi.escape(self.request.get('name')) profile.lastAccess = datetime.datetime.now() profile.put() scores = Score.all() scores = scores.filter("profilePublicKey =", profile.publicKey) for score in scores: score.name = profile.name score.put() profileData = {'privateKey': profile.privateKey, 'publicKey': profile.publicKey, 'name':profile.name, 'guest': profile.guest } self.response.headers['Content-Type'] = 'text/plain' self.response.out.write(json.dumps(profileData))
def get(self): scores = Score.all() for score in scores: score.year, score.month, score.week, score.day = dateutils.get_datetime_data(score.timestamp) score.put() self.response.headers['Content-Type'] = 'text/html' self.response.out.write("OK")
def get(self): scores = Score.all() for score in scores: score.year, score.month, score.week, score.day = dateutils.get_datetime_data( score.timestamp) score.put() self.response.headers['Content-Type'] = 'text/html' self.response.out.write("OK")
def post(self): privateKey = cgi.escape(self.request.get('privateKey')) profile = Profile.all().filter("privateKey =", privateKey).get() # should do nothing and tell no error, to avoid ppl searching for private keys? if (not profile): self.response.set_status(500, message="Can't find profile with key " + privateKey) return if (not profile.guest): self.response.set_status( 500, message= "Can't change an already registered profile when it is not guest" ) return profile.guest = False profile.name = cgi.escape(self.request.get('name')) profile.lastAccess = datetime.datetime.now() profile.put() scores = Score.all() scores = scores.filter("profilePublicKey =", profile.publicKey) for score in scores: score.name = profile.name score.put() profileData = { 'privateKey': profile.privateKey, 'publicKey': profile.publicKey, 'name': profile.name, 'guest': profile.guest } self.response.headers['Content-Type'] = 'text/plain' self.response.out.write(json.dumps(profileData))
def post(self): gameKey = cgi.escape(self.request.get('gameKey')) game = Game.all().filter("gameKey =", gameKey ).get() if(not game): self.response.set_status(500,message="Can't find game with key " + gameKey) return currentTime = datetime.datetime.now() score = Score() score.name = cgi.escape(self.request.get('name')) score.tags = self.request.get_all('tag') score.points = self.request.get_range('points') score.data = cgi.escape(self.request.get('data', '{}')) score.profilePublicKey = self.request.get('profilePublicKey', None) profilePrivateKey = self.request.get('profilePrivateKey', None) if (profilePrivateKey <> None): profilePrivateKey = cgi.escape(profilePrivateKey) profile = Profile.all().filter("privateKey =", profilePrivateKey).get() if (profile <> None): score.profilePublicKey = profile.publicKey score.name = profile.name # update profile last access time profile.lastAccess = currentTime profile.put() else: self.response.set_status(500,message="Can't find profile to submit score") return score.year, score.month, score.week, score.day = dateutils.get_datetime_data(currentTime) score.game = game score.put() self.response.headers['Content-Type'] = 'text/plain' self.response.out.write(score.key())
def score(self, game, name, tags, points, datetime, profilePublicKey = None): score = Score() score.game = game score.name = name if (profilePublicKey <> None): score.profilePublicKey = profilePublicKey score.points = points score.tags = tags score.data = "{}" score.timestamp = datetime score.year, score.month, score.week, score.day = dateutils.get_datetime_data(score.timestamp) score.put() return score
def post(self): gameKey = cgi.escape(self.request.get('gameKey')) game = Game.all().filter("gameKey =", gameKey).get() if (not game): self.response.set_status(500, message="Can't find game with key " + gameKey) return currentTime = datetime.datetime.now() score = Score() score.name = cgi.escape(self.request.get('name')) score.tags = self.request.get_all('tag') score.points = self.request.get_range('points') score.data = cgi.escape(self.request.get('data', '{}')) score.profilePublicKey = self.request.get('profilePublicKey', None) profilePrivateKey = self.request.get('profilePrivateKey', None) if (profilePrivateKey <> None): profilePrivateKey = cgi.escape(profilePrivateKey) profile = Profile.all().filter("privateKey =", profilePrivateKey).get() if (profile <> None): score.profilePublicKey = profile.publicKey score.name = profile.name # update profile last access time profile.lastAccess = currentTime profile.put() else: self.response.set_status( 500, message="Can't find profile to submit score") return score.year, score.month, score.week, score.day = dateutils.get_datetime_data( currentTime) score.game = game score.put() self.response.headers['Content-Type'] = 'text/plain' self.response.out.write(score.key())
def score(self, game, name, tags, points, datetime, profilePublicKey=None): score = Score() score.game = game score.name = name if (profilePublicKey <> None): score.profilePublicKey = profilePublicKey score.points = points score.tags = tags score.data = "{}" score.timestamp = datetime score.year, score.month, score.week, score.day = dateutils.get_datetime_data( score.timestamp) score.put() return score