def post(self, level_id): user = User.getLevelBlockUser(users.get_current_user()) if user: level = self.request.get('level') name = self.request.get('name') if level_id: l = Level.getById(int(level_id)) #only modify if you are the original author if l.user.id == user.key.id: l.name = name l.user = user.key l.score = 0 l.published = False l.level = str(level) l.put() else: l = Level() l.name = name l.user = user.key l.score = 0 l.published = False l.level = str(level) l.put() self.response.out.write(level) else: template_values = { 'signinurl': users.create_login_url("/") } template = jinja_environment.get_template('signin.html') self.response.out.write(template.render(template_values))
def post(self, levelid=""): user = User.getLevelBlockUser(users.get_current_user()) currentlevel = Level.getById(int(levelid)) action = self.request.get('done') if user: if action == 'true': self.response.headers['Content-Type'] = 'application/json' #check to see if level belongs to user and is if published if currentlevel.user.id == user.key.id: if not currentlevel.published: currentlevel.published = True currentlevel.played += 1 currentlevel.put() else: user.score += 1 user.put() self.response.out.write('{"points": 1, "publish": true}') else: score = 0 if currentlevel.jackpot: score = math.ceil(currentlevel.score * 0.5) creator = User.get_by_id(currentlevel.user.id()) creator.score += int(score) creator.put() currentlevel.jackpot = False currentlevel.played += 1 currentlevel.put() else: score += math.ceil(currentlevel.score * 0.1) user.score += int(score) user.put() self.response.out.write('{"points": ' + str(score) + ', "publish": false}') else: if currentlevel.published: if currentlevel.jackpot: currentlevel.score += 1 currentlevel.played += 1 currentlevel.put() else: template_values = { 'signinurl' : users.create_login_url("/") } template = jinja_environment.get_template('signin.html') self.response.out.write(template.render(template_values))
def get(self): user = User.getLevelBlockUser(users.get_current_user()) #checks to see if we have a user signed in if user: template_values = { 'levels' : Level.getUserLevels(user.key), 'currentuser': user.nickname } template = jinja_environment.get_template('userlevels.html') self.response.out.write(template.render(template_values)) #if not is ask them to sign in else: template_values = { 'signinurl' : users.create_login_url("/") } template = jinja_environment.get_template('signin.html') self.response.out.write(template.render(template_values))
def get(self, levelid=""): user = User.getLevelBlockUser(users.get_current_user()) #checks to see if we have a user signed in if user: currentlevel = Level.getById(int(levelid)) creator = User.get_by_id(currentlevel.user.id()) template_values = { 'level': currentlevel, 'creator': creator } template = jinja_environment.get_template('game.html') self.response.out.write(template.render(template_values)) #if not is ask them to sign in else: template_values = { 'signinurl' : users.create_login_url("/") } template = jinja_environment.get_template('signin.html') self.response.out.write(template.render(template_values))