示例#1
0
    def post(self):
        race = Race()

        if users.get_current_user():
            race.admin = users.get_current_user()

        race.name = self.request.get('name')
        race.description = self.request.get('description')
        race.status = "lobby"

        race.put()
        self.redirect('/race/' + str(race.key()))
示例#2
0
    def get(self, raceKey):

        if not users.get_current_user():
            """ If users are not logged in redirect to a login page """
            url = users.create_login_url(self.request.uri)
            self.redirect(url, False)
            return

        race = Race.get(raceKey)

        my_runner = self.raceService.joinRace(users.get_current_user(), race)

        channel_token = channel.create_channel(str(my_runner.key()))

        template_values = {
            'race_name': race.name,
            'race_key': raceKey,
            'race_description': race.description,
            'race_status': race.status,
            'runner_key': str(my_runner.key()),
            'runner_ready': "true" if my_runner.ready else "false",
            'channel_token': channel_token,
            'runners': self.raceService.getRunnersAsModel(race)
        }

        logging.error(my_runner.ready)

        path = os.path.join(os.path.dirname(__file__),
                            '../../templates/show-race.html')
        self.response.out.write(template.render(path, template_values))

        self.raceService.sendUpdateToRunners(my_runner, race)
示例#3
0
 def get(self, raceKey):
   
   if not users.get_current_user():
       """ If users are not logged in redirect to a login page """
       url = users.create_login_url(self.request.uri)
       self.redirect(url, False)
       return;
   
   race = Race.get(raceKey)
   
   my_runner = self.raceService.joinRace(users.get_current_user(), race)
   
   channel_token = channel.create_channel(str(my_runner.key()))
   
   template_values = {
     'race_name': race.name,
     'race_key': raceKey,
     'race_description': race.description,
     'race_status': race.status,
     'runner_key': str(my_runner.key()),
     'runner_ready' : "true" if my_runner.ready else "false",
     'channel_token': channel_token,
     'runners' : self.raceService.getRunnersAsModel(race)
   }
   
   
   logging.error(my_runner.ready);
   
   path = os.path.join(os.path.dirname(__file__), '../../templates/show-race.html')
   self.response.out.write(template.render(path, template_values))
   
   self.raceService.sendUpdateToRunners(my_runner, race)
示例#4
0
    def get(self, raceKey):
        race = Race.get(raceKey)
        runners = race.runner_set

        response = {}
        for runner in runners:
            email = str(runner.user)
            response[email] = runner.position

        self.response.out.write(simplejson.dumps(response))
示例#5
0
 def get(self, raceKey):
     race = Race.get(raceKey)
     runners = race.runner_set
 
     response = {}
     for runner in runners:
         email = str(runner.user)
         response[email] = runner.position
     
     self.response.out.write(simplejson.dumps(response))
示例#6
0
  def post(self):
    race = Race()

    if users.get_current_user():
      race.admin = users.get_current_user()

    race.name = self.request.get('name')
    race.description = self.request.get('description')
    race.status = "lobby"
    
    race.put()
    self.redirect('/race/' + str(race.key()))
示例#7
0
    def get(self, raceKey):
        """ Render a html portion showing the race podium """
        race = Race.get(raceKey)

        self.raceService.getRunnersAsModel(race)

        template_values = {'runners': self.raceService.getRunnersAsModel(race)}

        path = os.path.join(os.path.dirname(__file__),
                            '../../templates/show-race-podium.html')
        self.response.out.write(template.render(path, template_values))
示例#8
0
 def get(self, raceKey):
   """ Render a html portion showing the race podium """
   race = Race.get(raceKey)
   
   self.raceService.getRunnersAsModel(race)
   
   template_values = {
     'runners' : self.raceService.getRunnersAsModel(race)
   }
   
   path = os.path.join(os.path.dirname(__file__), '../../templates/show-race-podium.html')
   self.response.out.write(template.render(path, template_values))