QUA-002, premiere moitie. **Ce commit ne fait que reformater** : aucun changement de comportement, aucune ligne de logique touchee. 72 fichiers, 4 restaient deja conformes. Il est isole exprès, pour que `git log -p` sur les commits voisins reste lisible. `quote-style = "preserve"` etait deja pose dans pyproject.toml, ce qui evite le brassage guillemets simples / doubles : le diff porte sur les retours a la ligne, l indentation des appels longs et les virgules finales, pas sur le style de chaine. Verification : 263 tests passent avant et apres, ruff check propre. L activation en CI arrive dans le commit suivant, separement, pour que ce diff-ci ne contienne rien d autre. Co-Authored-By: Claude Opus 5 <[email protected]>
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""Player — registers for tryouts, manages their own profile."""
|
|
|
|
from app.models.user_model.user import User
|
|
|
|
|
|
class Player(User):
|
|
"""Player — registers for tryouts, manages their own profile."""
|
|
|
|
__mapper_args__ = {'polymorphic_identity': 'player'}
|
|
|
|
def get_visible_tryouts(self):
|
|
from app.models.tryout.tryout import Tryout
|
|
from app.models.match_model.match import Match
|
|
from app.models.participant.match_participant import MatchParticipant
|
|
|
|
# tryouts they registered for
|
|
player_tryout_ids = [r.tryout_id for r in self.tryout_registrations.all()]
|
|
tryouts = (
|
|
Tryout.query.filter(Tryout.id.in_(player_tryout_ids)).order_by(Tryout.date).all()
|
|
if player_tryout_ids
|
|
else []
|
|
)
|
|
|
|
# plus tryouts where they participate in a match
|
|
player_matches = (
|
|
Match.query.join(MatchParticipant)
|
|
.filter(
|
|
MatchParticipant.player_id == self.id,
|
|
)
|
|
.all()
|
|
)
|
|
extra_ids = set(m.tryout_id for m in player_matches)
|
|
extra = (
|
|
Tryout.query.filter(
|
|
Tryout.id.in_(extra_ids),
|
|
)
|
|
.order_by(Tryout.date)
|
|
.all()
|
|
if extra_ids
|
|
else []
|
|
)
|
|
|
|
all_ids = {t.id for t in tryouts}
|
|
return tryouts + [t for t in extra if t.id not in all_ids]
|