Improvements

clubs
Laurent 2 years ago
parent 46c5cbfe49
commit c144675cbc
  1. 6
      tournaments/models/event.py
  2. 27
      tournaments/models/group_stage.py
  3. 12
      tournaments/models/match.py
  4. 3
      tournaments/models/team_score.py
  5. 3
      tournaments/models/tournament.py
  6. 3
      tournaments/static/tournaments/css/broadcast.css
  7. 8
      tournaments/templates/tournaments/base.html
  8. 0
      tournaments/templates/tournaments/broadcasted_group_stages.html
  9. 6
      tournaments/templates/tournaments/match_cell.html
  10. 3
      tournaments/templates/tournaments/matches.html
  11. 170
      tournaments/templates/tournaments/summons.html
  12. 3
      tournaments/templates/tournaments/tournaments.html
  13. 1
      tournaments/urls.py
  14. 18
      tournaments/views.py

@ -16,3 +16,9 @@ class Event(models.Model):
def __str__(self): def __str__(self):
return self.name return self.name
def display_name(self):
if self.name:
return self.name
else:
return self.club.name

@ -21,3 +21,30 @@ class GroupStage(models.Model):
def matches_for_registration(self, player_registration): def matches_for_registration(self, player_registration):
team_scores = TeamScore.objects.filter(player_registrations=player_registration) team_scores = TeamScore.objects.filter(player_registrations=player_registration)
return map(lambda ts: ts.match, team_scores) return map(lambda ts: ts.match, team_scores)
def live_group_stage(self):
lgs = LiveGroupStage(self.name())
for team_registration in self.teamregistration_set.all():
team = GroupStageTeam(team_registration.team_names(), self.score(), self.diff())
lgs.add_team(team)
return lgs
def score(self):
return "2-0"
def diff(self):
return "+6"
class LiveGroupStage:
def __init__(self, title):
self.title = title
self.teams = []
def add_team(self, team):
self.teams.append(team)
class GroupStageTeam:
def __init__(self, names, score, diff):
self.names = names
self.score = score
self.diff = diff

@ -52,6 +52,9 @@ class Match(models.Model):
else: else:
return (timezone.now() - self.start_date).total_seconds() return (timezone.now() - self.start_date).total_seconds()
def started(self):
return timezone.now() > self.start_date
def durationPrefix(self): def durationPrefix(self):
if self.current_duration() > 0: if self.current_duration() > 0:
return "Temps de jeu" return "Temps de jeu"
@ -82,7 +85,8 @@ class Match(models.Model):
court = "" court = ""
if self.court: if self.court:
court = f"Terrain {self.court}" court = f"Terrain {self.court}"
livematch = LiveMatch(title, date, duration, court)
livematch = LiveMatch(title, date, duration, court, self.started())
for team_score in self.team_scores.all(): for team_score in self.team_scores.all():
image = team_score.team_registration.logo image = team_score.team_registration.logo
@ -104,15 +108,13 @@ class Team:
self.is_winner = is_winner self.is_winner = is_winner
class LiveMatch: class LiveMatch:
def __init__(self, title, date, duration, court): def __init__(self, title, date, duration, court, started):
self.title = title self.title = title
self.date = date self.date = date
self.teams = [] self.teams = []
self.duration = duration self.duration = duration
self.court = court self.court = court
self.started = started
def add_team(self, team): def add_team(self, team):
self.teams.append(team) self.teams.append(team)
# def toJSON(self):
# return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)

@ -27,4 +27,7 @@ class TeamScore(models.Model):
return names return names
def scores_array(self): def scores_array(self):
if self.score:
return [int(x) for x in self.score.split(',')] return [int(x) for x in self.score.split(',')]
else:
return []

@ -74,6 +74,9 @@ class Tournament(models.Model):
return map(lambda match: match.live_match(), matches) return map(lambda match: match.live_match(), matches)
def live_group_stages(self):
return map(lambda gs: gs.live_group_stage(), self.groupstage_set.all())
class TeamSummon: class TeamSummon:
def __init__(self, names, date, weight, stage, image): def __init__(self, names, date, weight, stage, image):
self.names = [] self.names = []

@ -14,5 +14,6 @@ body {
padding: 20px; padding: 20px;
background-color: white; background-color: white;
border-radius: 24px; border-radius: 24px;
/* box-shadow: 10px 10px lightblue; */ /* box-shadow: 0 0 0px 1px #fbead6; */
box-shadow: 0 0 0px 0px #fbead6;
} }

@ -27,17 +27,17 @@
<div class="grid-x"> <div class="grid-x">
<div class="cell medium-6 large-6 topblock my-block"> <div class="cell medium-6 large-6 topblock my-block">
<div class="bubble"> <!-- <div class="bubble"> -->
<img <img
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}" src="{% static 'tournaments/images/PadelClub_logo_512.png' %}"
class="logo inline" class="logo inline"
/> />
<div class="inline"> <div class="inline">
<h1 class="club">Bienvenue !</h1> <h1 class="club">{% block first_title %}Page Title{% endblock %}</h1>
<h1 class="event">{% block title %}Page Title{% endblock %}</h1> <h1 class="event">{% block second_title %}Page Title{% endblock %}</h1>
<!-- <span>Propulsé par Padel Club</span> --> <!-- <span>Propulsé par Padel Club</span> -->
</div> </div>
</div> <!-- </div> -->
</div> </div>
</div> </div>
<!-- Content --> <!-- Content -->

@ -27,9 +27,15 @@
{% endfor %} {% endfor %}
</div> </div>
<div class="table-cell alignright"> <div class="table-cell alignright">
{% if match.started %}
{% for score in team.scores %} {% for score in team.scores %}
<span class="score ws {% if team.is_winner %}winner{% endif %}">{{ score }}</span> <span class="score ws {% if team.is_winner %}winner{% endif %}">{{ score }}</span>
{% endfor %} {% endfor %}
{% else %}
<span class="score ws">{{ team.weight }}</span>
{% endif %}
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

@ -1,7 +1,8 @@
{% extends 'tournaments/base.html' %} {% extends 'tournaments/base.html' %}
{% block head_title %}Matchs{% endblock %} {% block head_title %}Matchs{% endblock %}
{% block title %}Matchs{% endblock %} {% block first_title %}{{ tournament.event.display_name }}{% endblock %}
{% block second_title %}{{ tournament.name }}{% endblock %}
{% block content %} {% block content %}
{% if matches %} {% if matches %}

@ -1,43 +1,12 @@
<html> {% extends 'tournaments/base.html' %}
{% load static %}
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link
rel="stylesheet"
href="{% static 'tournaments/css/foundation.min.css' %}"
/>
<link rel="stylesheet" href="{% static 'tournaments/css/style.css' %}" />
<link
rel="icon"
type="image/png"
href="{% static 'tournaments/images/favicon.png' %}"
/>
<title>Padel Club - Convocations</title> {% block head_title %}Matchs{% endblock %}
{% block first_title %}{{ tournament.name }}{% endblock %}
{% block second_title %}Convocations{% endblock %}
</head> {% block content %}
<body> {% load static %}
<div class="wrapper">
<main class="page-body">
<div class="container">
<div class="grid-x">
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<img
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}"
class="logo inline"
/>
<div class="inline">
<h1 class="club">4Padel Toulouse</h1>
<h1 class="event">Convocations</h1>
<!-- <span>Propulsé par Padel Club</span> -->
</div>
</div>
</div>
</div>
<div class="grid-x padding-bottom"> <div class="grid-x padding-bottom">
@ -66,116 +35,55 @@
</div> </div>
</div> </div>
<!-- <div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<div class="table-container bottom-border vertical-padding">
<img src="{% static 'tournaments/pc_icon_round_200.png' %}" class="team_image horizontal-margin">
<div class="w50 tight table-cell hpadding10">
<div>Razmig Sarkissian</div>
<div>Laurent Morvillier</div>
</div>
<div class="table-cell horizontal-padding">12299</div>
<div class="table-cell horizontal-padding large">17h30</div>
<div class="table-cell"><div class="mybox">Poule A</div></div>
</div>
<div class="table-container bottom-border vertical-padding">
<img src="pc_icon_round_200.png" class="team_image horizontal-margin">
<div class="w50 tight table-cell hpadding10">
<div>Razmig Sarkissian</div>
<div>Laurent Morvillier</div>
</div> </div>
{% endblock %}
<div class="table-cell horizontal-padding">12299</div>
<div class="table-cell horizontal-padding large">17h30</div>
<div class="table-cell"><div class="mybox">Poule A</div></div>
</div>
<div class="table-container bottom-border vertical-padding">
<img src="pc_icon_round_200.png" class="team_image horizontal-margin">
<div class="w50 tight table-cell hpadding10">
<div>Razmig Sarkissian</div>
<div>Laurent Morvillier</div>
</div>
<div class="table-cell horizontal-padding">12299</div>
<div class="table-cell horizontal-padding large">17h30</div>
<div class="table-cell"><div class="mybox">Poule A</div></div>
</div>
<div class="table-container bottom-border vertical-padding">
<img src="pc_icon_round_200.png" class="team_image horizontal-margin"> <!-- <html>
<div class="w50 tight table-cell hpadding10"> {% load static %}
<div>Razmig Sarkissian</div>
<div>Laurent Morvillier</div>
</div>
<div class="table-cell horizontal-padding">12299</div>
<div class="table-cell horizontal-padding large">17h30</div>
<div class="table-cell"><div class="mybox">Poule A</div></div>
</div>
<div class="table-container bottom-border vertical-padding">
<img src="pc_icon_round_200.png" class="team_image horizontal-margin">
<div class="w50 tight table-cell hpadding10">
<div>Razmig Sarkissian</div>
<div>Laurent Morvillier</div>
</div>
<div class="table-cell horizontal-padding">12299</div>
<div class="table-cell horizontal-padding large">17h30</div>
<div class="table-cell"><div class="mybox">Poule A</div></div>
</div>
<div class="table-container bottom-border vertical-padding">
<img src="pc_icon_round_200.png" class="team_image horizontal-margin"> <head>
<div class="w50 tight table-cell hpadding10"> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<div>Razmig Sarkissian</div> <link
<div>Laurent Morvillier</div> rel="stylesheet"
</div> href="{% static 'tournaments/css/foundation.min.css' %}"
/>
<link rel="stylesheet" href="{% static 'tournaments/css/style.css' %}" />
<div class="table-cell horizontal-padding">12299</div> <link
<div class="table-cell horizontal-padding large">17h30</div> rel="icon"
<div class="table-cell"><div class="mybox">Poule A</div></div> type="image/png"
</div> href="{% static 'tournaments/images/favicon.png' %}"
/>
<div class="table-container bottom-border vertical-padding"> <title>Padel Club - Convocations</title>
<img src="pc_icon_round_200.png" class="team_image horizontal-margin"> </head>
<div class="w50 tight table-cell hpadding10">
<div>Razmig Sarkissian</div>
<div>Laurent Morvillier</div>
</div>
<div class="table-cell horizontal-padding">12299</div> <body>
<div class="table-cell horizontal-padding large">17h30</div> <div class="wrapper">
<div class="table-cell"><div class="mybox">Poule A</div></div> <main class="page-body">
<div class="container">
<div class="grid-x">
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<img
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}"
class="logo inline"
/>
<div class="inline">
<h1 class="club">4Padel Toulouse</h1>
<h1 class="event">Convocations</h1>
<!-- <span>Propulsé par Padel Club</span> -->
</div> </div>
<div class="table-container bottom-border vertical-padding">
<img src="pc_icon_round_200.png" class="team_image horizontal-margin">
<div class="w50 tight table-cell hpadding10">
<div>Razmig Sarkissian</div>
<div>Laurent Morvillier</div>
</div> </div>
<div class="table-cell horizontal-padding">12299</div>
<div class="table-cell horizontal-padding large">17h30</div>
<div class="table-cell"><div class="mybox">Poule A</div></div>
</div> </div>
</div> </div>
</div> -->
</div> </div>
</div>
</main> </main>
</div> </div>
</body> </body>
</html> </html> -->

@ -1,7 +1,8 @@
{% extends 'tournaments/base.html' %} {% extends 'tournaments/base.html' %}
{% block head_title %}Tournois{% endblock %} {% block head_title %}Tournois{% endblock %}
{% block title %}Tournois{% endblock %} {% block first_title %}Padel Club{% endblock %}
{% block second_title %}Tournois{% endblock %}
{% block content %} {% block content %}

@ -8,5 +8,6 @@ urlpatterns = [
path('tournament/<str:tournament_id>/summons/', views.tournament_summons, name='tournament-summons'), path('tournament/<str:tournament_id>/summons/', views.tournament_summons, name='tournament-summons'),
path('tournament/<str:tournament_id>/broadcast/', views.tournament_matches, name='tournament-matches'), path('tournament/<str:tournament_id>/broadcast/', views.tournament_matches, name='tournament-matches'),
path('tournament/<str:tournament_id>/matches-json/', views.tournament_matches_json, name='tournament-matches-json'), path('tournament/<str:tournament_id>/matches-json/', views.tournament_matches_json, name='tournament-matches-json'),
path('tournament/<str:tournament_id>/live-group-stages-json/', views.tournament_live_group_stage_json, name='live-group-stages-json'),
path('players/', views.players, name='players'), path('players/', views.players, name='players'),
] ]

@ -36,6 +36,7 @@ def tournament(request, tournament_id):
live_matches = list(tournament.live_matches()) live_matches = list(tournament.live_matches())
return render(request, 'tournaments/matches.html', { return render(request, 'tournaments/matches.html', {
'tournament': tournament,
'matches': live_matches, 'matches': live_matches,
}) })
@ -45,22 +46,35 @@ def tournament_summons(request, tournament_id):
team_summons = tournament.team_summons() team_summons = tournament.team_summons()
return render(request, 'tournaments/summons.html', { return render(request, 'tournaments/summons.html', {
'tournament': tournament,
'team_summons': team_summons, 'team_summons': team_summons,
}) })
def tournament_matches(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
return render(request, 'tournaments/broadcasted_matches.html', {
'tournament': tournament,
})
def tournament_matches_json(request, tournament_id): def tournament_matches_json(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id) tournament = get_object_or_404(Tournament, pk=tournament_id)
live_matches = list(tournament.live_matches()) live_matches = list(tournament.live_matches())
data = json.dumps(live_matches, default=vars) data = json.dumps(live_matches, default=vars)
return HttpResponse(data, content_type='application/json') return HttpResponse(data, content_type='application/json')
def tournament_matches(request, tournament_id): def tournament_live_group_stage(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id) tournament = get_object_or_404(Tournament, pk=tournament_id)
return render(request, 'tournaments/broadcasted_matches.html', { return render(request, 'tournaments/broadcasted_group_stages.html', {
'tournament': tournament, 'tournament': tournament,
}) })
def tournament_live_group_stage_json(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
live_group_stages = list(tournament.live_group_stages())
data = json.dumps(live_group_stages, default=vars)
return HttpResponse(data, content_type='application/json')
def players(request): def players(request):
return render(request, 'tournaments/test.html') return render(request, 'tournaments/test.html')

Loading…
Cancel
Save