Minor improvements

clubs
Laurent 2 years ago
parent c75ce4afc1
commit a000dd4d6b
  1. 2
      tournaments/admin.py
  2. 14
      tournaments/models/group_stage.py
  3. 7
      tournaments/models/match.py
  4. 4
      tournaments/models/team_registration.py
  5. 99
      tournaments/templates/tournaments/group_stage_cell.html
  6. 6
      tournaments/templates/tournaments/match_cell.html
  7. 19
      tournaments/templates/tournaments/tournaments.html

@ -24,7 +24,7 @@ class CustomUserAdmin(UserAdmin):
]
class TeamRegistrationAdmin(admin.ModelAdmin):
list_display = ['player_names', 'name', 'tournament']
list_display = ['player_names', 'group_stage_position', 'name', 'tournament']
class TournamentAdmin(admin.ModelAdmin):
list_display = ['name', 'event', 'is_private', 'start_date']

@ -79,10 +79,10 @@ class GroupStage(models.Model):
team1.diff += total1 - total2
team2.diff += total2 - total1
if len(self.match_set.all()) == 0:
teams = sorted(gs_teams.values(), key=lambda team: team.position)
else:
if len(self.match_set.filter(end_date__isnull=False).all()) > 0:
teams = sorted(gs_teams.values(), key=lambda team: -(team.wins * 100 + team.diff))
else:
teams = sorted(gs_teams.values(), key=lambda team: team.position)
for team in teams:
lgs.add_team(team)
@ -131,10 +131,14 @@ class GroupStageTeam:
self.wins = 0
self.losses = 0
self.diff = 0
self.weight = team_registration.weight()
def wins_losses(self):
return f"{self.wins}/{self.losses}"
def match_count(self):
return self.wins + self.losses
def formatted_diff(self):
if self.diff >= 0:
return f"+{self.diff}"
@ -145,5 +149,7 @@ class GroupStageTeam:
return {
"names": self.names,
"win_loss": self.wins_losses(),
"diff": self.formatted_diff()
"diff": self.formatted_diff(),
"weight": self.weight,
"match_count": self.match_count(),
}

@ -118,7 +118,8 @@ class Match(models.Model):
if self.court:
court = f"Terrain {self.court}"
livematch = LiveMatch(title, date, duration, court, self.started())
ended = self.end_date is not None
livematch = LiveMatch(title, date, duration, court, self.started(), ended)
for team_score in self.sorted_team_scores():
image = team_score.team_registration.logo
@ -169,13 +170,14 @@ class Team:
}
class LiveMatch:
def __init__(self, title, date, duration, court, started):
def __init__(self, title, date, duration, court, started, ended):
self.title = title
self.date = date
self.teams = []
self.duration = duration
self.court = court
self.started = started
self.ended = ended
def add_team(self, team):
self.teams.append(team)
@ -188,6 +190,7 @@ class LiveMatch:
"duration": self.duration,
"court": self.court,
"started": self.started,
"ended": self.ended,
}
def has_walk_out(self):

@ -2,6 +2,7 @@ from django.db import models
from django.db.models.sql.query import Q
from . import Tournament, GroupStage, Match
import uuid
from django.utils import timezone
class TeamRegistration(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
@ -38,7 +39,8 @@ class TeamRegistration(models.Model):
def next_match(self):
all_matches = [ts.match for ts in self.teamscore_set.all()]
all_matches = sorted(all_matches, key=lambda m: m.start_date)
now = timezone.now()
all_matches = sorted(all_matches, key=lambda m: m.start_date if m.start_date is not None else now)
matches = [m for m in all_matches if m.end_date is None]
if matches:
return matches[0]

@ -1,61 +1,44 @@
{% load static %}
<div class="cell large-3 my-block">
<div class="dark_bubble">
<div class="flex-row">
<label class="left-label matchtitle winner">{{ group_stage.title }}</label>
<!-- <label class="right-label info">{{ match.date }}</label> -->
</div>
<div>
{% for team in group_stage.teams %}
<div class="table-row-2-colums dark-bottom-border">
<div class="table-cell table-cell-large">
{% for name in team.names %}
<div class="semibold {% if team.is_winner %}winner{% endif %}">
{{ name }}
</div>
{% endfor %}
</div>
<div class="table-cell center">
<div class="score ws">{{ team.wins_losses }}</div>
<div class="ws">{{ team.formatted_diff }}</div>
</div>
</div>
<!-- <div class="table-row-3-colums team-names-box {% cycle 'bottom-border' '' %} padding-bottom-small">
<div class="table-cell table-cell-large">
{% for name in team.names %}
<div class="semibold {% if team.is_winner %}winner{% endif %}">
{{ name }}
</div>
{% endfor %}
</div>
<div class="table-cell alignright">
{% if match.started %}
{% for score in team.scores %}
<span class="score ws {% if team.is_winner %}winner{% endif %}">{{ score }}</span>
{% endfor %}
{% else %}
<span class="score ws">{{ team.weight }}</span>
{% endif %}
</div>
</div> -->
{% endfor %}
</div>
<div class="flex-row top-margin">
<label class="left-label minor-info semibold"><span class="beige">{{ group_stage.formatted_duration }}</span></label>
<!-- <label class="right-label minor-info">{{ match.court }}</label> -->
<!-- <a href="" class="right-label">{{ match.court }}</a> -->
</div>
</div>
<div class="cell large-3 my-block">
<div class="dark_bubble">
<div class="flex-row">
<label class="left-label matchtitle winner">{{ group_stage.title }}</label>
<!-- <label class="right-label info">{{ match.date }}</label> -->
</div>
<div>
{% for team in group_stage.teams %}
<div class="table-row-2-colums dark-bottom-border">
<div class="table-cell table-cell-large">
{% for name in team.names %}
<div class="semibold {% if team.is_winner %}winner{% endif %}">
{{ name }}
</div>
{% endfor %}
</div>
<div class="table-cell center">
{% if team.match_count == 0 %}
<div class="score ws">{{ team.weight }}</div>
{% else %}
<div class="score ws">{{ team.wins_losses }}</div>
<div class="ws">{{ team.formatted_diff }}</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
<div class="flex-row top-margin">
<label class="left-label minor-info semibold"><span class="beige">{{ group_stage.formatted_duration }}</span></label>
<!-- <label class="right-label minor-info">{{ match.court }}</label> -->
<!-- <a href="" class="right-label">{{ match.court }}</a> -->
</div>
</div>
</div>

@ -50,7 +50,11 @@
{{ match.duration }}
{% endif %}
</label>
<label class="right-label minor-info">{{ match.court }}</label>
<label class="right-label minor-info">
{% if not match.ended %}
{{ match.court }}
{% endif %}
</label>
<!-- <a href="" class="right-label">{{ match.court }}</a> -->
</div>

@ -17,27 +17,36 @@
{% if live or future %}
<div class="grid-x">
{% if live %}
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
{% if live %}
<label class="title">En cours</label>
{% for tournament in live %}
{% include 'tournaments/tournament_row.html' %}
{% endfor %}
{% endif %}
</div>
</div>
{% if future %}
{% endif %}
<label class="title top-margin20">À venir</label>
{% if future %}
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<label class="title">À venir</label>
{% for tournament in future %}
{% include 'tournaments/tournament_row.html' %}
{% endfor %}
{% endif %}
</div>
{% endif %}
</div>
{% endif %}

Loading…
Cancel
Save