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. 5
      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. 12
      tournaments/templates/tournaments/match_cell.html
  10. 3
      tournaments/templates/tournaments/matches.html
  11. 178
      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):
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):
team_scores = TeamScore.objects.filter(player_registrations=player_registration)
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:
return (timezone.now() - self.start_date).total_seconds()
def started(self):
return timezone.now() > self.start_date
def durationPrefix(self):
if self.current_duration() > 0:
return "Temps de jeu"
@ -82,7 +85,8 @@ class Match(models.Model):
court = ""
if 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():
image = team_score.team_registration.logo
@ -104,15 +108,13 @@ class Team:
self.is_winner = is_winner
class LiveMatch:
def __init__(self, title, date, duration, court):
def __init__(self, title, date, duration, court, started):
self.title = title
self.date = date
self.teams = []
self.duration = duration
self.court = court
self.started = started
def add_team(self, 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
def scores_array(self):
return [int(x) for x in self.score.split(',')]
if self.score:
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)
def live_group_stages(self):
return map(lambda gs: gs.live_group_stage(), self.groupstage_set.all())
class TeamSummon:
def __init__(self, names, date, weight, stage, image):
self.names = []

@ -14,5 +14,6 @@ body {
padding: 20px;
background-color: white;
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="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<!-- <div class="bubble"> -->
<img
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}"
class="logo inline"
/>
<div class="inline">
<h1 class="club">Bienvenue !</h1>
<h1 class="event">{% block title %}Page Title{% endblock %}</h1>
<h1 class="club">{% block first_title %}Page Title{% endblock %}</h1>
<h1 class="event">{% block second_title %}Page Title{% endblock %}</h1>
<!-- <span>Propulsé par Padel Club</span> -->
</div>
</div>
<!-- </div> -->
</div>
</div>
<!-- Content -->

@ -27,9 +27,15 @@
{% endfor %}
</div>
<div class="table-cell alignright">
{% for score in team.scores %}
<span class="score ws {% if team.is_winner %}winner{% endif %}">{{ score }}</span>
{% endfor %}
{% 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 %}

@ -1,7 +1,8 @@
{% extends 'tournaments/base.html' %}
{% 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 %}
{% if matches %}

@ -1,45 +1,14 @@
<html>
{% load static %}
{% extends 'tournaments/base.html' %}
<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' %}" />
{% block head_title %}Matchs{% endblock %}
{% block first_title %}{{ tournament.name }}{% endblock %}
{% block second_title %}Convocations{% endblock %}
<link
rel="icon"
type="image/png"
href="{% static 'tournaments/images/favicon.png' %}"
/>
{% block content %}
<title>Padel Club - Convocations</title>
</head>
<body>
<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>
{% load static %}
<div class="grid-x padding-bottom">
<div class="grid-x padding-bottom">
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
@ -66,116 +35,55 @@
</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 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">
<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>
<!-- <html>
{% load static %}
<div class="table-container bottom-border vertical-padding">
<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' %}" />
<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>
<link
rel="icon"
type="image/png"
href="{% static 'tournaments/images/favicon.png' %}"
/>
<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">
<title>Padel Club - Convocations</title>
<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>
</head>
<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>
<body>
<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>
</div>
</main>
</div>
</body>
</html>
</html> -->

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

@ -8,5 +8,6 @@ urlpatterns = [
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>/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'),
]

@ -36,6 +36,7 @@ def tournament(request, tournament_id):
live_matches = list(tournament.live_matches())
return render(request, 'tournaments/matches.html', {
'tournament': tournament,
'matches': live_matches,
})
@ -45,22 +46,35 @@ def tournament_summons(request, tournament_id):
team_summons = tournament.team_summons()
return render(request, 'tournaments/summons.html', {
'tournament': tournament,
'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):
tournament = get_object_or_404(Tournament, pk=tournament_id)
live_matches = list(tournament.live_matches())
data = json.dumps(live_matches, default=vars)
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)
return render(request, 'tournaments/broadcasted_matches.html', {
return render(request, 'tournaments/broadcasted_group_stages.html', {
'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):
return render(request, 'tournaments/test.html')

Loading…
Cancel
Save