diff --git a/api/views.py b/api/views.py index e17f741..7f14fd2 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,8 +409,12 @@ 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}') + 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) + xls = pd.ExcelFile(full_path) sheet_names = xls.sheet_names # Determine which sheet to use @@ -419,13 +426,14 @@ 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') + 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"' diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index fc3ff50..ff9bc80 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -840,6 +840,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 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)) 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 @@ -
+