diff --git a/tournaments/templates/tournaments/navigation_base.html b/tournaments/templates/tournaments/navigation_base.html
index 91c9752..7e07f5e 100644
--- a/tournaments/templates/tournaments/navigation_base.html
+++ b/tournaments/templates/tournaments/navigation_base.html
@@ -1,18 +1,18 @@
-
-
+
diff --git a/tournaments/urls.py b/tournaments/urls.py
index 3d14290..7b400c3 100644
--- a/tournaments/urls.py
+++ b/tournaments/urls.py
@@ -81,5 +81,6 @@ urlpatterns = [
path('stripe-onboarding-complete/', views.stripe_onboarding_complete, name='stripe-onboarding-complete'),
path('stripe-refresh-account-link/', views.stripe_refresh_account_link, name='stripe-refresh-account-link'),
path('tournaments//toggle-private/', views.toggle_tournament_private, name='toggle_tournament_private'),
+ path("private-tournaments/", views.private_tournaments, name="private-tournaments"),
]
diff --git a/tournaments/views.py b/tournaments/views.py
index 6d98079..816c2ce 100644
--- a/tournaments/views.py
+++ b/tournaments/views.py
@@ -1702,6 +1702,63 @@ def toggle_tournament_private(request, tournament_id):
messages.error(request, f'Erreur: {str(e)}')
return redirect('tournament-info', tournament_id=tournament_id)
+def private_tournaments(request):
+ """
+ View for displaying private tournaments (staff-only).
+ Similar to index, but shows private tournaments instead.
+ """
+ if not request.user.is_staff:
+ messages.error(request, 'Accès non autorisé')
+ return redirect('index')
+
+ now = timezone.now()
+ thirty_days_ago = now - timedelta(days=30)
+ thirty_days_future = now + timedelta(days=30)
+
+ # Custom query for private tournaments
+ queries = [
+ Q(is_private=True, is_deleted=False, event__club__isnull=False)
+ ]
+
+ # Filter by date range for future tournaments
+ future_query = queries.copy()
+ future_query.append(Q(start_date__gt=now, start_date__lte=thirty_days_future))
+
+ # Filter for live tournaments
+ live_query = queries.copy()
+ live_query.append(Q(start_date__lte=now, end_date__isnull=True) | Q(start_date__lte=now, end_date__gt=now))
+
+ # Filter for ended tournaments
+ ended_query = queries.copy()
+ ended_query.append(Q(end_date__lte=now, end_date__gte=thirty_days_ago))
+
+ # Get the tournaments from the database
+ future_tournaments = Tournament.objects.filter(*future_query).prefetch_related(
+ 'group_stages', 'rounds', 'team_registrations').order_by('start_date')
+
+ live_tournaments = Tournament.objects.filter(*live_query).prefetch_related(
+ 'group_stages', 'rounds', 'team_registrations').order_by('start_date')
+
+ ended_tournaments = Tournament.objects.filter(*ended_query).prefetch_related(
+ 'group_stages', 'rounds', 'team_registrations').order_by('-end_date')
+
+ # Filter tournaments that should be displayed
+ future = [t for t in future_tournaments if t.display_tournament()]
+ live = [t for t in live_tournaments if t.display_tournament()]
+ ended = [t for t in ended_tournaments if t.display_tournament()]
+
+ return render(
+ request,
+ "tournaments/tournaments.html",
+ {
+ 'future': future[:10],
+ 'live': live[:10],
+ 'ended': ended[:10],
+ 'is_private_section': True, # Flag to indicate we're in the private tournaments section
+ 'section_title': 'Tournois privés', # Title for the private tournaments page
+ }
+ )
+
class UserListExportView(LoginRequiredMixin, View):
def get(self, request, *args, **kwargs):
users = CustomUser.objects.order_by('date_joined')