Example #1
0
 def post_sync(self):
     
     # Parses the entered date and updates the model
     self.model.tournament_dt = datetime.datetime.strptime(self.formatted_tournament_dt.value, DT_FORMAT).date()
     
     # Reshuffles the tournaments so that they are still ordered by date
     Season.get(self.model.season_id).reorder_tournaments()
Example #2
0
 def f(value, field):
     
     # Step 1 : general format check with the standard library
     year = _generic_dt_validator(value, dt_format)
     
     # Step 2 : year check
     selected_season = Season.get(field.parent.season_id.value)
     allowed_years = (selected_season.start_year, selected_season.end_year)
     if not year in allowed_years:
         raise validators.ValidationError("Year should be %s" % " or ".join(map(str,allowed_years))) 
Example #3
0
 def post_sync(self):
     
     # Parses the entered date and updates the model
     self.model.tournament_dt = datetime.datetime.strptime(self.formatted_tournament_dt.value, DT_FORMAT).date() 
     
     # Appends the tournament in the end of the collection (i.e. in last position)
     # The tournament should be appended to the season and not just be added to the session :
     # see the collection_class used at the Season level to store tournaments
     season = Season.get(self.model.season_id)
     season.tournaments.append(self.model)
     
     # Reshuffles the tournaments so that they are still ordered by date
     season.reorder_tournaments()
Example #4
0
    def GET(self, season_id):
        season = Season.get(int(season_id))
        results = []
        # Groups the results by user (works because the results are ordered)
        for _, iter_raw_results_by_player in groupby(season.raw_results, lambda r: r.tournament_id):
            results.append({
                raw_result.user_id: raw_result.score 
                for raw_result in iter_raw_results_by_player
            })

        return {
            "players": {player.id: player.pseudonym for player in season.players},
            "results": results
        }
Example #5
0
    def GET(self, season_id):
        season = Season.get(int(season_id))
        results = []
        # Groups the results by user (works because the results are ordered)
        for _, iter_raw_results_by_player in groupby(
                season.raw_results, lambda r: r.tournament_id):
            results.append({
                raw_result.user_id: raw_result.score
                for raw_result in iter_raw_results_by_player
            })

        return {
            "players":
            {player.id: player.pseudonym
             for player in season.players},
            "results": results
        }
Example #6
0
 def GET(self, season_id):
     season = Season.get(int(season_id))
     return config.views.layout(
         config.views.season(season, config.views.results(season)))
Example #7
0
 def GET(self, season_id):
     season = Season.get(int(season_id))
     return config.views.layout(
         config.views.season(season, config.views.results(season))
     )