def txn(fit): result = Result.get_by_key_name('best') if result is None: result = Result(key_name='best', fitness=fit) elif result.fitness > fit: result.fitness = fit result.put()
def do_body(self, args): """Render the HTML for all the results, and provide enough information to edit an game""" data = { 'url_args': args, } year = self.get_year(args) if year == ALL_YEARS: data['rounds'] = Round.gql('ORDER BY date ASC') else: data['rounds'] = Round.gql('WHERE year = :1 ORDER BY date ASC', year) tpath = os.path.join(DeeWhyPage.TEMPLATE_DIR, 'rounds.html') self.response.out.write(template.render(tpath, data)) data = { 'url_args': args, } # Get the full data for the given round so they can edit it if args.has_key('round'): round_num = args['round'] round_key = Round.get_key(round_num, year) result_key = Result.get_key(round_num, year) if round_key != '': curr_round = Round.get_by_key_name(round_key) if curr_round: data['players'] = [ p.player for p in TeamList.gql('WHERE year = :1', curr_round.date.year) ] data['players'].sort(self.sort_players) data['round'] = curr_round curr_result = Result.get_by_key_name(result_key) if curr_result: data['result'] = curr_result if curr_result.other_goals == 0: curr_result.other_goals = None if curr_result.own_goals == 0: curr_result.own_goals = None #if curr_result.deewhy_forfeit: # curr_result.deewhy_goals = 0 # curr_result.opponent_goals = 5 #elif curr_result.opponent_forfeit: # curr_result.deewhy_goals = 5 # curr_result.opponent_goals = 0 tpath = os.path.join(DeeWhyPage.TEMPLATE_DIR, 'manage_results.html') self.response.out.write(template.render(tpath, data))