|
|
|
@ -79,16 +79,16 @@ class Match(models.Model): |
|
|
|
def player_names(self): |
|
|
|
def player_names(self): |
|
|
|
return map(lambda ts: ts.player_names(), self.team_scores.all()) |
|
|
|
return map(lambda ts: ts.player_names(), self.team_scores.all()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def local_start_date(self): |
|
|
|
|
|
|
|
timezone = self.tournament().timezone() |
|
|
|
|
|
|
|
return self.start_date.astimezone(timezone) |
|
|
|
|
|
|
|
|
|
|
|
def formatted_start_date(self): |
|
|
|
def formatted_start_date(self): |
|
|
|
if self.start_date: |
|
|
|
if self.start_date: |
|
|
|
timezone = self.tournament().timezone() |
|
|
|
local_start = self.local_start_date() |
|
|
|
local_start = self.start_date.astimezone(timezone) |
|
|
|
|
|
|
|
# timezoned_datetime = timezone.localtime(self.start_date) |
|
|
|
|
|
|
|
return formats.date_format(local_start, format='H:i') |
|
|
|
return formats.date_format(local_start, format='H:i') |
|
|
|
# return formats.date_format(self.start_date, format='H:i') |
|
|
|
|
|
|
|
else: |
|
|
|
else: |
|
|
|
return '' |
|
|
|
return '' |
|
|
|
# return str(self.start_date) #.strftime("%H:%M") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def time_indication(self): |
|
|
|
def time_indication(self): |
|
|
|
if self.end_date: |
|
|
|
if self.end_date: |
|
|
|
@ -100,8 +100,10 @@ class Match(models.Model): |
|
|
|
if self.started(): |
|
|
|
if self.started(): |
|
|
|
return self.formatted_duration() |
|
|
|
return self.formatted_duration() |
|
|
|
else: |
|
|
|
else: |
|
|
|
timezoned_datetime = timezone.localtime(self.start_date) |
|
|
|
# timezoned_datetime = timezone.localtime(self.start_date) |
|
|
|
return formats.date_format(timezoned_datetime, format='l H:i') |
|
|
|
timezone = self.tournament().timezone() |
|
|
|
|
|
|
|
local_start = self.start_date.astimezone(timezone) |
|
|
|
|
|
|
|
return formats.date_format(local_start, format='l H:i') |
|
|
|
else: |
|
|
|
else: |
|
|
|
return 'À venir...' |
|
|
|
return 'À venir...' |
|
|
|
|
|
|
|
|
|
|
|
@ -188,14 +190,14 @@ class Match(models.Model): |
|
|
|
def live_match(self): |
|
|
|
def live_match(self): |
|
|
|
title = self.name if self.name else self.backup_name() |
|
|
|
title = self.name if self.name else self.backup_name() |
|
|
|
date = self.formatted_start_date() |
|
|
|
date = self.formatted_start_date() |
|
|
|
duration = self.time_indication() |
|
|
|
time_indication = self.time_indication() |
|
|
|
court = self.court_name(self.court_index) |
|
|
|
court = self.court_name(self.court_index) |
|
|
|
group_stage_name = None |
|
|
|
group_stage_name = None |
|
|
|
if self.group_stage: |
|
|
|
if self.group_stage: |
|
|
|
group_stage_name = self.group_stage.display_name() |
|
|
|
group_stage_name = self.group_stage.display_name() |
|
|
|
|
|
|
|
|
|
|
|
ended = self.end_date is not None |
|
|
|
ended = self.end_date is not None |
|
|
|
livematch = LiveMatch(title, date, duration, court, self.started(), ended, group_stage_name) |
|
|
|
livematch = LiveMatch(title, date, time_indication, court, self.started(), ended, group_stage_name) |
|
|
|
|
|
|
|
|
|
|
|
for team_score in self.sorted_team_scores(): |
|
|
|
for team_score in self.sorted_team_scores(): |
|
|
|
if team_score.team_registration: |
|
|
|
if team_score.team_registration: |
|
|
|
@ -257,11 +259,11 @@ class Team: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class LiveMatch: |
|
|
|
class LiveMatch: |
|
|
|
def __init__(self, title, date, duration, court, started, ended, group_stage_name): |
|
|
|
def __init__(self, title, date, time_indication, court, started, ended, group_stage_name): |
|
|
|
self.title = title |
|
|
|
self.title = title |
|
|
|
self.date = date |
|
|
|
self.date = date |
|
|
|
self.teams = [] |
|
|
|
self.teams = [] |
|
|
|
self.duration = duration |
|
|
|
self.time_indication = time_indication |
|
|
|
self.court = court |
|
|
|
self.court = court |
|
|
|
self.started = started |
|
|
|
self.started = started |
|
|
|
self.ended = ended |
|
|
|
self.ended = ended |
|
|
|
@ -278,7 +280,7 @@ class LiveMatch: |
|
|
|
"title": self.title, |
|
|
|
"title": self.title, |
|
|
|
"date": self.date, |
|
|
|
"date": self.date, |
|
|
|
"teams": [team.to_dict() for team in self.teams], |
|
|
|
"teams": [team.to_dict() for team in self.teams], |
|
|
|
"duration": self.duration, |
|
|
|
"time_indication": self.time_indication, |
|
|
|
"court": self.court, |
|
|
|
"court": self.court, |
|
|
|
"started": self.started, |
|
|
|
"started": self.started, |
|
|
|
"ended": self.ended, |
|
|
|
"ended": self.ended, |
|
|
|
@ -286,7 +288,7 @@ class LiveMatch: |
|
|
|
"group_stage_name": self.group_stage_name, |
|
|
|
"group_stage_name": self.group_stage_name, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def show_duration(self): |
|
|
|
def show_time_indication(self): |
|
|
|
for team in self.teams: |
|
|
|
for team in self.teams: |
|
|
|
if team.walk_out and len(team.scores) == 0: |
|
|
|
if team.walk_out and len(team.scores) == 0: |
|
|
|
return False |
|
|
|
return False |
|
|
|
|