Test and fixes

clubs
Laurent 2 years ago
parent 5b953494cf
commit 8f692793a8
  1. 2
      tournaments/models/club.py
  2. 2
      tournaments/models/custom_user.py
  3. 2
      tournaments/models/event.py
  4. 2
      tournaments/models/group_stage.py
  5. 2
      tournaments/models/match.py
  6. 2
      tournaments/models/player_registration.py
  7. 2
      tournaments/models/round.py
  8. 2
      tournaments/models/team_registration.py
  9. 2
      tournaments/models/team_score.py
  10. 2
      tournaments/models/tournament.py
  11. 3
      tournaments/serializers.py
  12. 2
      tournaments/static/tournaments/Padeltest.html
  13. 184
      tournaments/templates/tournaments/test.html
  14. 1
      tournaments/urls.py
  15. 2
      tournaments/views.py

@ -2,7 +2,7 @@ from django.db import models
import uuid
class Club(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
name = models.CharField(max_length=50)
acronym = models.CharField(max_length=10)
phone = models.CharField(max_length=15, null=True, blank=True)

@ -5,7 +5,7 @@ import uuid
class CustomUser(AbstractUser):
pass
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
umpire_code = models.CharField(max_length=50, blank=True, null=True)
clubs = models.ManyToManyField(Club)
phone = models.CharField(max_length=15, null=True, blank=True)

@ -3,7 +3,7 @@ from . import Club, FederalMatchCategory
import uuid
class Event(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
club = models.ForeignKey(Club, on_delete=models.CASCADE)
date = models.DateTimeField()
name = models.CharField(max_length=200, null=True, blank=True)

@ -3,7 +3,7 @@ from . import Tournament, FederalMatchCategory
import uuid
class GroupStage(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE)
index = models.IntegerField(null=True, blank=True)
format = models.IntegerField(default=FederalMatchCategory.NINE_GAMES, choices=FederalMatchCategory.choices, null=True, blank=True)

@ -4,7 +4,7 @@ from django.utils import timezone
import uuid
class Match(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
round = models.ForeignKey(Round, null=True, blank=True, on_delete=models.CASCADE)
group_stage = models.ForeignKey(GroupStage, null=True, blank=True, on_delete=models.CASCADE)
start_date = models.DateTimeField(null=True, blank=True)

@ -3,7 +3,7 @@ from . import TeamRegistration
import uuid
class PlayerRegistration(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
team_registration = models.ForeignKey(TeamRegistration, on_delete=models.CASCADE)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)

@ -3,7 +3,7 @@ from . import Tournament, FederalMatchCategory
import uuid
class Round(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE)
index = models.IntegerField(null=True, blank=True)
loser = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)

@ -3,7 +3,7 @@ from . import Tournament, GroupStage
import uuid
class TeamRegistration(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE)
group_stage = models.ForeignKey(GroupStage, null=True, blank=True, on_delete=models.SET_NULL)
registration_date = models.DateTimeField(null=True, blank=True)

@ -3,7 +3,7 @@ from . import Match, TeamRegistration, PlayerRegistration
import uuid
class TeamScore(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
match = models.ForeignKey(Match, on_delete=models.CASCADE, related_name="team_scores")
team_registration = models.ForeignKey(TeamRegistration, on_delete=models.CASCADE, null=True, blank=True)
player_registrations = models.ManyToManyField(PlayerRegistration, blank=True)

@ -3,7 +3,7 @@ from . import Event, CustomUser, FederalMatchCategory, FederalCategory, FederalL
import uuid
class Tournament(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
event = models.ForeignKey(Event, blank=True, null=True, on_delete=models.CASCADE)
creator = models.ForeignKey(CustomUser, blank=True, null=True, on_delete=models.CASCADE)
name = models.CharField(max_length=200, null=True, blank=True)

@ -67,8 +67,9 @@ class MatchSerializer(serializers.ModelSerializer):
class TeamScoreSerializer(serializers.ModelSerializer):
class Meta:
# match_id = serializers.PrimaryKeyRelatedField(queryset=Match.objects.all())
# player_registrations_ids = serializers.Man
model = TeamScore
fields = ['id', 'match_id', 'score', 'walk_out', 'lucky_loser']
fields = ['id', 'match_id', 'score', 'walk_out', 'lucky_loser', 'player_registrations']
class TeamRegistrationSerializer(serializers.ModelSerializer):
class Meta:

@ -5,7 +5,7 @@
<link rel="stylesheet" href="css/style.css" />
<link rel="icon" type="image/png" href="images/favicon.png" />
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<title>Padel</title>
</head>

@ -0,0 +1,184 @@
{% load static %}
<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' %}" />
<link rel="icon" type="image/png" href="{% static 'tournaments/images/favicon.png' %}" />
<title>Padel</title>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
</head>
<body x-data="{
players: null,
active: 1,
screens: 2,
retrievePlayers() {
fetch('/api/player-registrations/')
.then(res => res.json())
.then((data) => {
this.players = data
})
},
loop() {
this.retrievePlayers()
setInterval(() => {
this.retrievePlayers()
this.active = this.active === this.screens ? 1 : this.active+1
}, 3000)
}
}" x-init="loop()">
<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">Planning</h1>
<!-- <span>Propulsé par Padel Club</span> -->
</div>
</div>
</div>
</div>
<template x-if="players">
<div class="grid-x padding-bottom">
<div class="cell medium-6 large-6 topblock my-block">
<!-- <template x-for="(player, index) in players" >
<div x-data="{
addOpeningTagIfNecessary(index) {
Return index % 2 ? ‘<div class='bubble'>’ : ‘’;
},
addClosingTagIfNecessary(index) {
Return index % 2 ? ‘</div>’ : ‘’;
}
}">
<div x-html=“addOpeningTagIfNecessary(index)”></div>
<span x-text="player.first_name"></span> <span x-text="player.last_name"></span>
<div x-html=“addClosingTagIfNecessary(index)”></div>
</div>
</template> -->
<template x-for="(player, index) in players" >
<div x-data="{
doHTML: function(index) {
let bubble = (index % 2 === 0) ? true : false;
let html = ``;
if(bubble) html+= `<div class='bubble'>`;
html = `<span x-text='player.first_name'></span> <span x-text='player.last_name'></span>`;
if(bubble) html+= `</div>`;
return html;
},
}" x-html="doHTML(index)">
</div>
</template>
<!-- <template x-for="(player, index) in players" >
<div x-data="{
doHTML: function(index) {
let bubble = index % 2 ? true : false;
let html = '';
if(bubble) html+= '<div class='bubble'>';
html += '<span x-text='player.first_name'></span> <span x-text='player.last_name'></span>';
if(bubble) html += '</div>';
return html;
},
}" x-html="doHTML(index)">
</div>
</template> -->
<!-- <div class="bubble" x-show="active === 1">
<label class="title">Équipes</label>
<template x-for="team in tournament.teamregistration_set" >
<div class="table-container bottom-border vertical-padding">
<img src="{% static 'tournaments/images/pc_icon_round_200.png' %}" class="team_image horizontal-margin">
<div class="w50 tight table-cell hpadding10">
<template x-for="player in team.playerregistration_set">
<div>
<div x-text="player.first_name"></div> <div x-text="player.last_name"></div>
</div>
</template>
</div>
<div class="table-cell horizontal-padding">
<span x-text="team.court"></span>
</div>
<div class="table-cell horizontal-padding large">
<span x-text="team.call_date"></span>
</div>
<div class="table-cell"><div class="mybox">Poule A</div></div>
</div>
</template>
</div>
<div class="bubble" x-show="active === 2">
<label class="title">Matchs</label>
<template x-for="round in tournament.round_set">
<template x-for="match in round.match_set">
<div>
<div class="flex-row">
<label class="left-label matchtitle">{{ match.id }}</label>
<label class="right-label info">{{ match.start_date }}</label>
</div>
<div>
{% for team in match.team_states %}
<div class="test bottom-border padding-bottom-small">
<div class="left-label">
{% for name in team.names %}
<div class="winner">
{{ name }}
</div>
{% endfor %}
</div>
<div class="">
{% for score in team.scores %}
<span class="score ws {% if team.is_winner %}winner{% endif %}">{{ score }}</span>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
<div class="top-margin flex-row">
<label class="left-label minor-info">{{ match.duration }}</label>
</div>
</div>
</template>
</template>
</div> -->
</div>
</div>
</template>
</div>
</main>
</div>
</body>
</html>

@ -7,4 +7,5 @@ urlpatterns = [
path('tournament/<str:tournament_id>/', views.tournament, name='tournament'),
path('tournament/<str:tournament_id>/summons/', views.tournament_summons, name='tournament-summons'),
path('tournament/<str:tournament_id>/json/', views.tournament_json, name='tournament-json'),
path('players/', views.players, name='players'),
]

@ -54,6 +54,8 @@ def tournament_json(request, tournament_id):
data = json.dumps(live_matches, default=vars)
return HttpResponse(data, content_type='application/json')
def players(request):
return render(request, 'tournaments/test.html')
@api_view(['GET'])
def user_by_token(request):

Loading…
Cancel
Save