fix naming crash

sync
Laurent 8 months ago
parent 98781235a1
commit 7e84e3ab9e
  1. 6
      tournaments/models/tournament.py
  2. 6
      tournaments/views.py

@ -1013,9 +1013,9 @@ class Tournament(BaseModel):
def is_build_and_not_empty(self): def is_build_and_not_empty(self):
if hasattr(self, '_prefetched_objects_cache'): if hasattr(self, '_prefetched_objects_cache'):
# Use prefetched data if available # Use prefetched data if available
has_group_stages = 'groupstage_set' in self._prefetched_objects_cache and len(self.group_stages.all()) > 0 has_group_stages = 'group_stages' in self._prefetched_objects_cache and len(self.group_stages.all()) > 0
has_rounds = 'round_set' in self._prefetched_objects_cache and len(self.rounds.all()) > 0 has_rounds = 'rounds' in self._prefetched_objects_cache and len(self.rounds.all()) > 0
has_team_registrations = 'teamregistration_set' in self._prefetched_objects_cache and len(self.team_registrations.all()) >= 4 has_team_registrations = 'team_registrations' in self._prefetched_objects_cache and len(self.team_registrations.all()) >= 4
else: else:
# Fall back to database queries if not prefetched # Fall back to database queries if not prefetched
has_group_stages = self.group_stages.count() > 0 has_group_stages = self.group_stages.count() > 0

@ -159,9 +159,9 @@ def tournaments_query(query, club_id, ascending, limit=None):
sortkey = '-start_date' sortkey = '-start_date'
queryset = Tournament.objects.filter(*queries).prefetch_related( queryset = Tournament.objects.filter(*queries).prefetch_related(
'groupstage_set', 'group_stages',
'round_set', 'rounds',
'teamregistration_set', 'team_registrations',
).order_by(sortkey) ).order_by(sortkey)
# Apply limit directly in the database query # Apply limit directly in the database query

Loading…
Cancel
Save