Closed climu closed 3 years ago
Hum this happens even without a player in it. This error is also raised:
ValueError: invalid literal for int() with base 10: ''
at https://github.com/climu/openstudyroom/blob/f0a4c6a23f7ff8feeb085c13a135c23a052ffcee/league/views.py#L1559
with player being <LeaguePlayer: 7636: lyra33, The Shell #4>
properly defined.
We introduced some "wontplay" sgf so there were a difference between https://github.com/climu/openstudyroom/blob/46115b7915caa962f2903b93194514aede198d5a/league/views.py#L1499 and https://github.com/climu/openstudyroom/blob/46115b7915caa962f2903b93194514aede198d5a/league/views.py#L1557
Should we just change the nb_games method ?
event.sgf_set.filter(Q(black=user) | Q(white=user)).count()
to something like this
event.sgf_set.filter(Q(Q(black=user) | Q(white=user)) & ~Q(result='WontPlay')).count()
I fixed it in 46115b7 like that:
def get_sgfs(self):
"""Return a queryset of all valid player SGF"""
user = self.user
event = self.event
return event.sgf_set.exclude(winner__isnull=True).filter(
Q(black=user) | Q(white=user))
then we use this in nb_games
, nb_win
and nb_loss
.
If we ever want to change that we just have to update the get_sgfs
methods.
If a player already is in a league and an admin try to add it again via the populate tool we have a 500 because:
happens here: https://github.com/climu/openstudyroom/blob/f0a4c6a23f7ff8feeb085c13a135c23a052ffcee/league/views.py#L1560-L1564
We should detect that and warn the admins in populate view that render a preview.