From 41e91796933340349e686220d725e20e24582c5f Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 8 May 2025 09:26:40 +0200 Subject: [PATCH 1/8] adds logging for csv issue --- api/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/views.py b/api/views.py index e17f741..765cef7 100644 --- a/api/views.py +++ b/api/views.py @@ -29,6 +29,9 @@ from django.core.files.storage import default_storage from django.core.files.base import ContentFile import os from django.http import HttpResponse +import logging + +logger = logging.getLogger(__name__) @api_view(['GET']) def user_by_token(request): @@ -406,6 +409,8 @@ def xls_to_csv(request): file_path = os.path.join(directory, uploaded_file.name) file_name = default_storage.save(file_path, ContentFile(uploaded_file.read())) + logger.info(f'file saved at {file_name}') + # Check available sheets and look for 'inscriptions' xls = pd.ExcelFile(file_name) sheet_names = xls.sheet_names From 840c42209c78f9399cf1d5b659a08b1d45e50c94 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 8 May 2025 09:30:00 +0200 Subject: [PATCH 2/8] adds more logging --- api/views.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/views.py b/api/views.py index 765cef7..d9d390a 100644 --- a/api/views.py +++ b/api/views.py @@ -410,6 +410,8 @@ def xls_to_csv(request): file_name = default_storage.save(file_path, ContentFile(uploaded_file.read())) logger.info(f'file saved at {file_name}') + full_path = default_storage.path(file_name) + logger.info(f'full_path = {full_path}') # Check available sheets and look for 'inscriptions' xls = pd.ExcelFile(file_name) From 75c66c98d2e5589505db7699b6ceb515a29db24a Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 8 May 2025 09:32:01 +0200 Subject: [PATCH 3/8] attempt to fix xls-to-csv issu --- api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/views.py b/api/views.py index d9d390a..9154ff2 100644 --- a/api/views.py +++ b/api/views.py @@ -414,7 +414,7 @@ def xls_to_csv(request): logger.info(f'full_path = {full_path}') # Check available sheets and look for 'inscriptions' - xls = pd.ExcelFile(file_name) + xls = pd.ExcelFile(full_path) sheet_names = xls.sheet_names # Determine which sheet to use From 92e50b55ddb89e0d61388c30de6ae0577c644110 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 8 May 2025 09:33:34 +0200 Subject: [PATCH 4/8] attempt #2 --- api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/views.py b/api/views.py index 9154ff2..2b07f9f 100644 --- a/api/views.py +++ b/api/views.py @@ -426,7 +426,7 @@ def xls_to_csv(request): break # Convert to csv and save - data_xls = pd.read_excel(file_name, sheet_name=target_sheet, index_col=None) + data_xls = pd.read_excel(full_path, sheet_name=target_sheet, index_col=None) csv_file_name = create_random_filename('players', 'csv') output_path = os.path.join(directory, csv_file_name) data_xls.to_csv(output_path, sep=';', index=False, encoding='utf-8') From ba4f6652ed305a1120eaec1afeb70aeac2e3508e Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 8 May 2025 09:36:41 +0200 Subject: [PATCH 5/8] attempt #3 --- api/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/views.py b/api/views.py index 2b07f9f..7f14fd2 100644 --- a/api/views.py +++ b/api/views.py @@ -429,10 +429,11 @@ def xls_to_csv(request): data_xls = pd.read_excel(full_path, sheet_name=target_sheet, index_col=None) csv_file_name = create_random_filename('players', 'csv') output_path = os.path.join(directory, csv_file_name) - data_xls.to_csv(output_path, sep=';', index=False, encoding='utf-8') + full_output_path = default_storage.path(output_path) + data_xls.to_csv(full_output_path, sep=';', index=False, encoding='utf-8') # Send the processed file back - with default_storage.open(output_path, 'rb') as file: + with default_storage.open(full_output_path, 'rb') as file: response = HttpResponse(file.read(), content_type='application/octet-stream') response['Content-Disposition'] = f'attachment; filename="players.csv"' From d474de1edfe692d8229a9e373b22a65c1627ccd0 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 8 May 2025 16:32:51 +0200 Subject: [PATCH 6/8] Fix group stage display --- .../tournaments/broadcast/broadcasted_group_stage.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_group_stage.html b/tournaments/templates/tournaments/broadcast/broadcasted_group_stage.html index 2c3556d..6bcd53e 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_group_stage.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_group_stage.html @@ -39,7 +39,7 @@ -
+
From 9be436fccfdff7cef9658dcf203c30453740dc72 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 8 May 2025 16:45:37 +0200 Subject: [PATCH 7/8] attempt to fix broadcast display --- tournaments/models/tournament.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 6ddcafa..c387860 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -838,6 +838,7 @@ class Tournament(BaseModel): matches = [m for m in matches if m.should_appear() and (m.start_date is None or m.start_date <= future_threshold) and # Not starting in more than 1h (m.end_date is None or m.end_date >= past_threshold)] # Not finished for more than 1h + matches.sort(key=lambda m: (m.start_date is not None)) # display started matches matches = matches[:16] matches.sort(key=lambda m: (m.start_date is None, m.end_date is not None, m.start_date, m.index)) From 47f867c2f792b3f018db61b30d0ee072d5aa1170 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 8 May 2025 16:47:32 +0200 Subject: [PATCH 8/8] attempt to fix #2 --- tournaments/models/tournament.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index c387860..0410418 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -838,7 +838,7 @@ class Tournament(BaseModel): matches = [m for m in matches if m.should_appear() and (m.start_date is None or m.start_date <= future_threshold) and # Not starting in more than 1h (m.end_date is None or m.end_date >= past_threshold)] # Not finished for more than 1h - matches.sort(key=lambda m: (m.start_date is not None)) # display started matches + matches.sort(key=lambda m: (m.start_date is None)) # display started matches matches = matches[:16] matches.sort(key=lambda m: (m.start_date is None, m.end_date is not None, m.start_date, m.index))