diff --git a/scores/migrations/0026_tournament_date.py b/scores/migrations/0026_tournament_date.py new file mode 100644 index 0000000..e327718 --- /dev/null +++ b/scores/migrations/0026_tournament_date.py @@ -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'), + ), + ] diff --git a/scores/models.py b/scores/models.py index 144fb45..ac73b4b 100644 --- a/scores/models.py +++ b/scores/models.py @@ -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 diff --git a/scores/serializers.py b/scores/serializers.py index 799e632..aa208ad 100644 --- a/scores/serializers.py +++ b/scores/serializers.py @@ -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: diff --git a/scores/templates/scores/club.html b/scores/templates/scores/club.html index a952493..f82a592 100644 --- a/scores/templates/scores/club.html +++ b/scores/templates/scores/club.html @@ -18,10 +18,23 @@
+ {% if tv %} +
+

mode TV activé

+ désactiver le mode tv +
+ {% else %} +
+

mode TV désactivé

+ activer le mode tv +
+ {% endif %} + {% for tournament in tournaments %}