sol.models.player -- Players

class sol.models.player.Player(**kwargs)

A single person.

acceptedDiscernibility()

Determine whether the player's name should be obfuscated or not.

The player may have already explicitly stated his privacy policy agreement, and in such case we honor his will, showing the full name only when he agrees.

Otherwise, we check if he participated to any tournaments after January 1, 2020: if so, assume he implicitly accepted the common clause that requires one to agree in order to play in public tourneys.

caption(html=None, localized=True, css_class=None, ignore_privacy=False, omit_nickname=False)

Description of the player, made up concatenating his names.

classmethod check_insert(session: Session, fields: dict[str, Any], user_id: str | int) None

Prevent duplicated players.

check_update(fields: dict[str, Any], user_id: str | int) None

Perform any check before updating the instance.

delete()

Prevent deletion if this player is involved in some tourney.

classmethod find(session, lastname, firstname, nickname, guid=None)

Find a player, even after it has been merged into another.

Parameters:
  • session -- an SQLAlchemy session

  • lastname -- a string, the last name of the player

  • firstname -- a string, the first name of the player

  • nickname -- a string, the nick name of the player

  • guid -- the hex string of an UUID

Return type:

a tuple

This tries to find the given player by looking for it first in the players table then in the merged_players table, either by guid or by name.

If found, it returns a tuple with the current player (that is, the eventual target of the merge) and a boolean flag, False when it is current or True if it has been merged.

If not found it returns a (None, False) tuple.

matchesSummary()

Return the number of won, lost, tied and single matches.

mergePlayers(other_players, clogger=None)

Merge multiple players into a single one.

Parameters:

other_players -- a sequence of players ids or guids, or tuples like (guid, lastname, firstname, nickname)

Return type:

a list of replaced players descriptions

This will replace the specified players with this one wherever they participated to a game, either in singles or team events.

This is obviously possible only when the specified players didn't play together in any tourney.

The old names are stored in the table merged_players with a reference to the current player (that is, self), so that they can be correctly resolved in the future.

opponentMatches(opponent)

Return the list of matches against the opponent.

opponents()

Return a summary of the opponents this player met, in singles.

participations()

Return the list of competitors involving this player.

sendTrainingURL(request, match, cnum, opponent)

Send an email containing the URL to edit the scores of a match.

Parameters:
  • request -- the web request

  • match -- the Match instance

  • cnum (int) -- the concurrent number

  • opponent -- the opponent Player instance, or None for the Phantom

sendTrainingURLs(request, matches)

Send an email containing the URLs to edit the scores of a player's matches.

Parameters:
  • request -- the web request

  • matches -- a sequence of tuples (match, concurrent number, opponent)

serialize(serializer: Serializer) SerializedPlayer

Reduce a single player to a simple dictionary.

Parameters:

serializer -- a Serializer instance

Return type:

dict

Returns:

a plain dictionary containing a flatified view of this player

shouldOmitNickName(_non_word_letters=re.compile('\\W'))

Determine if the nickname should be omitted because redundant.

agreedprivacy: Mapped[str]

Whether the player explicitly accepted the privacy policy: A means agreed, N means did not agree.

When left blank, this gets implicitly inferred from whether the person participated to a tournament after January 1, 2020.

His name and other details will be dimmed if he did not agree.

birthdate: Mapped[date | None]

Date of birth of the player.

citizenship: Mapped[bool]

Whether the player belongs legally to the given country or not.

club: Mapped[Club | None]

The club this player is associated to.

property country

The name of the player's country.

property description

Description of the player, made up concatenating his names.

email: Mapped[str | None]

Email address of the player.

federation: Mapped[Club | None]

The federation this player is associated to.

firstname: Mapped[str]

Player's first name.

idclub: Mapped[int | None]

Membership club's ID.

idfederation: Mapped[int | None]

Membership federation's ID.

idowner: Mapped[int | None]

ID of the user that is responsible for this record.

idplayer: Mapped[int]

Primary key.

language: Mapped[str | None]

The ISO code of the preferred language of the player.

lastname: Mapped[str]

Player's last name.

merged: Mapped[list[Player]]

A possibly empty list of players that has been merged into this one.

modified: Mapped[datetime]

Last update timestamp.

nationality: Mapped[str]

ISO country code to compute national rankings.

nickname: Mapped[str]

Player's nickname.

owner: Mapped[User]

The owner of this record, admin when None.

portrait: Mapped[str | None]

Picture of the player, used by lit.

This is just the filename, referencing a picture inside the sol.portraits_dir directory.

sex: Mapped[str | None]

Player's gender: F means female, M means male.