add tv mode and date in club view

main
Razmig Sarkissian 2 years ago
parent be505c42e9
commit 17d83c72c3
  1. 18
      scores/migrations/0026_tournament_date.py
  2. 15
      scores/models.py
  3. 2
      scores/serializers.py
  4. 13
      scores/templates/scores/club.html

@ -0,0 +1,18 @@
# Generated by Django 4.2 on 2023-11-28 17:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('scores', '0025_remove_match_teams_match_teamone_match_teamtwo'),
]
operations = [
migrations.AddField(
model_name='tournament',
name='date',
field=models.DateTimeField(blank=True, null=True, verbose_name='start date'),
),
]

@ -19,7 +19,22 @@ class Tournament(models.Model):
auto_scrolling = models.BooleanField(default=False)
shortname = models.CharField(max_length=200, blank=True)
tournament_index = models.IntegerField(default=0)
date = models.DateTimeField('start date', null=True, blank=True)
def hasStartDate(self):
if self.date:
return True
else:
return False
def localizedStartDate(self):
locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
_seconds = 0
if self.date:
return localtime(self.date).strftime("%A %d %B %Y")
else:
return ""
def __str__(self):
return self.name

@ -16,7 +16,7 @@ class ClubSerializer(serializers.HyperlinkedModelSerializer):
class TournamentSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Tournament
fields = ['id', 'name', 'club', 'auto_scrolling', 'shortname', 'tournament_index']
fields = ['id', 'name', 'club', 'auto_scrolling', 'shortname', 'tournament_index', 'date']
class MatchSerializer(serializers.HyperlinkedModelSerializer):
class Meta:

@ -18,10 +18,23 @@
<main class="page-body">
{% if tv %}
<div class="center">
<h1>mode TV activé</h1>
<a href="/club/{{ club.name }}">désactiver le mode tv</a>
</div>
{% else %}
<div class="center">
<h1>mode TV désactivé</h1>
<a href="/tv/club/{{ club.name }}">activer le mode tv</a>
</div>
{% endif %}
{% for tournament in tournaments %}
<div class="sbig">
<ul>
{{ tournament.localizedStartDate }}
{% if tv %}
<li><a href="/tv/club/{{ tournament.club.name }}/tournoi/{{ tournament.id }}/">{{ tournament.name }}</a> | <a href="/tv/club/{{ tournament.club.name }}/tournoi/{{ tournament.id }}/classement">Classement</a> | <a href="/tv/club/{{ tournament.club.name }}/tournoi/{{ tournament.id }}/equipes">Équipes</a> | <a href="/tv/club/{{ tournament.club.name }}/tournoi/{{ tournament.id }}/poules">Poules</a></li>
{% else %}

Loading…
Cancel
Save