def __rich_str__(self, link=None): name = field_render(self.name, link_target_url(self, link)) games = ", ".join([ field_render(g.name, link_target_url(g, link)) for g in self.games.all() ]) return f'{name} - {games}'
def __rich_str__(self, link=None): if self.session is None: # Don't crash of the rank is orphaned! game = "<no game>" team_play = False ranker = field_render(self.player, link) else: game = field_render(self.session.game, link) team_play = self.session.team_play ranker = field_render(self.team, link) if team_play else field_render( self.player, link) return u'{} - {} - {}'.format( game, field_render(self.rank, link_target_url(self, link)), ranker)
def __rich_str__(self, link=None): if self.session is None: # Don't crash of the performance is orphaned! when = "<no time>" game = "<no game>" else: when = self.session.date_time game = field_render(self.session.game, link) performer = field_render(self.player, link) performance = "{:.0%} participation, play number {}, {:+.1f} teeth".format( self.partial_play_weighting, self.play_number, self.trueskill_eta_after - self.trueskill_eta_before) return u'{} - {:%d, %b %Y} - {}: {}'.format( game, when, performer, field_render(performance, link_target_url(self, link)))
def __rich_str__(self, link=None): games = self.games_played if len(games) > 2: game_str = ", ".join( map(lambda g: field_render(g, link), games[0:1])) + "..." elif len(games) > 0: game_str = ", ".join(map(lambda g: field_render(g, link), games)) else: game_str = html.escape("<No Game>") name = field_render(self.name, link_target_url( self, link)) if self.name else "" return name + u" (" + u", ".join( [field_render(p, link) for p in self.players.all()]) + u") for " + game_str
def __detail_str__(self, link=None): if self.session is None: # Don't crash of the rank is orphaned! game = "<no game>" team_play = False ranker = field_render(self.player, link) mode = "individual" else: game = field_render(self.session.game, link) team_play = self.session.team_play ranker = field_render(self.team, link) if team_play else field_render( self.player, link) mode = "team" if team_play else "individual" return u'{} - {} - {} ({} play)'.format( game, field_render(self.rank, link_target_url(self, link)), ranker, mode)
def __detail_str__(self, link=None): detail = self.__rich_str__(link) detail += "<UL>" for p in self.players.all(): detail += "<LI>{}</LI>".format(field_render(p, link)) detail += "</UL>" return detail
def __detail_str__(self, link=None): detail = self.__rich_str__(link) lps = self.leaderboard_positions detail += "<BR>Leaderboard positions:<UL>" for league in lps: detail += "<LI>in League: {}</LI><UL>".format( field_render(league, link)) for game in lps[league]: detail += "<LI>{}: {}</LI>".format(field_render(game, link), lps[league][game]) detail += "</UL>" detail += "</UL>" return detail
def __rich_str__(self, link=None): name = field_render(self.name, link_target_url(self, link)) pmin = self.min_players pmax = self.max_players beta = self.trueskill_beta tau = self.trueskill_tau * 100 p = int(self.trueskill_p * 100) return f'{name} (plays {pmin}-{pmax}), Skill factor: {beta:0.2f}, Draw probability: {p:d}%, Skill dynamics factor: {tau:0.2f}'
def __detail_str__(self, link=None): rules = {} for r in self.rules.all(): rules[r.game] = r game_detail = {} for g in self.games.all(): if g in rules: game_detail[g] = field_render( g.name, link_target_url(g, link) ) + f": min_plays={rules[g].min_plays}, weight={rules[g].weight}" else: game_detail[g] = field_render(g.name, link_target_url( g, link)) + "Error: rules are missing!" name = field_render(self.name, link_target_url(self, link)) games = "</li><li>".join([game_detail[g] for g in self.games.all()]) games = f"<ul><li>{games}</li></ul" return f'{name}:{games}'
def __detail_str__(self, link=None): if self.name: detail = field_render(self.name, link_target_url(self, link)) else: detail = html.escape("<Nameless Team>") games = self.games_played if len(games) > 2: game_str = ", ".join( map(lambda g: field_render(g, link), games[0:1])) + "..." elif len(games) > 0: game_str = ", ".join(map(lambda g: field_render(g, link), games)) else: game_str = html.escape("<no game>") detail += " for " + game_str + "<UL>" for p in self.players.all(): detail += "<LI>{}</LI>".format(field_render(p, link)) detail += "</UL>" return detail
def field_str(model, pk, link=None, fmt=None): ''' See: https://docs.djangoproject.com/en/4.0/topics/cache/#the-low-level-cache-api :param model: The name of a model :param pk: A primary key value for that model (object id) :param attribute: The name of an attribute of such an object (a model field or method) ''' Model = apps.get_model(APP, model) obj = Model.objects.get(pk=pk) return field_render(obj, link, fmt)
def __detail_str__(self, link=None): if self.session is None: # Don't crash of the performance is orphaned! when = "<no time>" game = "<no game>" players = "<no players>" else: when = self.session.date_time game = field_render(self.session.game, link) players = len(self.session.players) performer = field_render(self.player, link) detail = u'{} - {:%a, %-d %b %Y} - {}:<UL>'.format( game, when, performer) detail += "<LI>Players: {}</LI>".format(players) detail += "<LI>Play number: {}</LI>".format(self.play_number) detail += "<LI>Play Weighting: {:.0%}</LI>".format( self.partial_play_weighting) detail += "<LI>Trueskill Delta: {:+.1f} teeth</LI>".format( self.trueskill_eta_after - self.trueskill_eta_before) detail += "<LI>Victories: {}</LI>".format(self.victory_count) detail += "</UL>" return detail
def __rich_str__(self, link=None): return u"{} (manager: {})".format(field_render(self, link), field_render(self.manager, link))
def __rich_str__(self, link=None): leagues = list(self.leagues.all()) leagues = list(map(lambda l: field_render(l, link), leagues)) return u"{} (used by: {})".format(field_render(self, link), ", ".join(leagues))
def __rich_str__(self, link=None): tourney_name = field_render(self.tourney.name, link_target_url(self.tourney, link)) game_name = field_render(self.game.name, link_target_url(self.game, link)) return f'{tourney_name} - {game_name}: min_plays={self.min_plays}, weight={self.weight}'
def __rich_str__(self, link=None): return u'{} - {}'.format( field_render(self.__verbose_str__(), link_target_url(self, link)), field_render(self.email_address, link if link == flt.none else flt.mailto))