Raz 6 months ago
commit f8be173ad8
  1. 16
      api/views.py
  2. 1
      tournaments/models/tournament.py
  3. 2
      tournaments/templates/tournaments/broadcast/broadcasted_group_stage.html

@ -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"'

@ -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))

@ -39,7 +39,7 @@
</div>
</div>
<div x-show="group_stage.teams[i-1].match_count > 0 && group_stage.started === true">
<div x-show="group_stage.started === true">
<div class="score ws numbers"><span x-text="group_stage.teams[i-1].win_loss"></span></div>
<div class="ws numbers"><span x-text="group_stage.teams[i-1].diff"></span></div>
</div>

Loading…
Cancel
Save