From fe1592837427c92114a7af648f37f9460213622a Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 24 Feb 2023 10:00:26 +0100 Subject: [PATCH] Added header/footer and improved UI --- .../0006_club_footer_club_header.py | 23 +++ scores/models.py | 2 + scores/static/scores/style.css | 40 ++++- scores/templates/scores/index.html | 78 ++++---- scores/templates/scores/match.html | 168 ++++++++++-------- scores/views.py | 4 +- 6 files changed, 201 insertions(+), 114 deletions(-) create mode 100644 scores/migrations/0006_club_footer_club_header.py diff --git a/scores/migrations/0006_club_footer_club_header.py b/scores/migrations/0006_club_footer_club_header.py new file mode 100644 index 0000000..1eac887 --- /dev/null +++ b/scores/migrations/0006_club_footer_club_header.py @@ -0,0 +1,23 @@ +# Generated by Django 4.1.1 on 2023-02-24 08:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('scores', '0005_match_team5'), + ] + + operations = [ + migrations.AddField( + model_name='club', + name='footer', + field=models.CharField(blank=True, max_length=200), + ), + migrations.AddField( + model_name='club', + name='header', + field=models.CharField(blank=True, max_length=200), + ), + ] diff --git a/scores/models.py b/scores/models.py index 5eaa339..34f2516 100644 --- a/scores/models.py +++ b/scores/models.py @@ -3,6 +3,8 @@ from django.utils import timezone class Club(models.Model): name = models.CharField(max_length=200) + header = models.CharField(max_length=200, blank=True) + footer = models.CharField(max_length=200, blank=True) def __str__(self): return self.name diff --git a/scores/static/scores/style.css b/scores/static/scores/style.css index 1b1b509..f53bbcf 100644 --- a/scores/static/scores/style.css +++ b/scores/static/scores/style.css @@ -1,11 +1,36 @@ -html { +html, body { /* font-size: 30px; /* px signifie 'pixels': la taille de base pour la police est désormais 10 pixels de haut */ /* font-family: 'Open Sans', sans-serif; /* cela devrait être le reste du résultat obtenu à partir de Google fonts */ font-family: Helvetica, sans-serif; background-color: #3878D8; color: white; + + +box-sizing: border-box; +height: 100%; +padding: 0; +margin: 0; +} + +header, footer { + padding: 15px; +} + +header { + font-size: 30px; +} + +.page-body { + flex-grow: 1; +} + +.wrapper { + box-sizing: border-box; + min-height: 100%; + display: flex; + flex-direction: column; } a { @@ -13,7 +38,7 @@ a { } table { - font-size: 30px; /* px signifie 'pixels': la taille de base pour la police est désormais 10 pixels de haut */ + font-size: 30px; font-weight: 600; } @@ -31,6 +56,10 @@ td { padding: 10px; } +.big { + font-size: 30px; +} + .score { width: 60px; text-align: center; @@ -50,7 +79,7 @@ td { } .smatch { - padding-top: 100px; + padding-top: 50px; width: 800px; margin: 0 auto; @@ -67,7 +96,10 @@ td { align-items: center; } - +.page-footer { + flex-grow: 0; + flex-shrink: 0; +} .container { /* width: 100%; */ /* text-align:center; */ diff --git a/scores/templates/scores/index.html b/scores/templates/scores/index.html index f6c7e2f..4114a2b 100644 --- a/scores/templates/scores/index.html +++ b/scores/templates/scores/index.html @@ -9,41 +9,48 @@ var countDownDate = new Date("Jan 5, 2024 15:37:25").getTime(); // Update the count down every 1 second var x = setInterval(function() { - // Get today's date and time - var now = new Date().getTime(); - - // Find the distance between now and the count down date - var distance = {{ match.seconds }} * -1; - - // Time calculations for days, hours, minutes and seconds - var days = Math.floor(distance / (1000 * 60 * 60 * 24)); - var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); - var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); - var seconds = Math.floor((distance % (1000 * 60)) / 1000); - - // Display the result in the element with id="demo" - document.getElementById("demo").innerHTML = hours + "h " - + minutes + "m " + seconds + "s "; - - // If the count down is finished, write some text - if (distance < 0) { - clearInterval(x); - document.getElementById("demo").innerHTML = "Démarrage en cours..."; - } +// Get today's date and time +var now = new Date().getTime(); + +// Find the distance between now and the count down date +var distance = {{ match.seconds }} * -1; + +// Time calculations for days, hours, minutes and seconds +var days = Math.floor(distance / (1000 * 60 * 60 * 24)); +var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); +var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); +var seconds = Math.floor((distance % (1000 * 60)) / 1000); + +// Display the result in the element with id="demo" +document.getElementById("demo").innerHTML = hours + "h " ++ minutes + "m " + seconds + "s "; + +// If the count down is finished, write some text +if (distance < 0) { +clearInterval(x); +document.getElementById("demo").innerHTML = "Démarrage en cours..."; +} }, 1000); --> Padel - + +
-
-{% if matches %} -{% for match in matches %} -
+ {% if club.header %} +
{{ club.header }}
+ {% endif %} + +
+ +
+ {% if matches %} + {% for match in matches %} +

COURS #{{ match.court }}

@@ -94,15 +101,22 @@ var x = setInterval(function() { -

{{ match.duration }}

+

{{ match.duration }}

+ +
+ {% endfor %} + {% else %} +

Pas de matchs en cours...

+ {% endif %}
- {% endfor %} -{% else %} -

Pas de matchs en cours...

-{% endif %} -
+ + + {% if club.footer %} +
{{ club.footer }}
+ {% endif %} +
diff --git a/scores/templates/scores/match.html b/scores/templates/scores/match.html index 0dfc185..725a628 100644 --- a/scores/templates/scores/match.html +++ b/scores/templates/scores/match.html @@ -9,96 +9,110 @@ var countDownDate = new Date("Jan 5, 2024 15:37:25").getTime(); // Update the count down every 1 second var x = setInterval(function() { - // Get today's date and time - var now = new Date().getTime(); - - // Find the distance between now and the count down date - var distance = countDownDate - now; - - // Time calculations for days, hours, minutes and seconds - var days = Math.floor(distance / (1000 * 60 * 60 * 24)); - var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); - var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); - var seconds = Math.floor((distance % (1000 * 60)) / 1000); - - // Display the result in the element with id="demo" - document.getElementById("demo").innerHTML = hours + "h " - + minutes + "m " + seconds + "s "; - - // If the count down is finished, write some text - if (distance < 0) { - clearInterval(x); - document.getElementById("demo").innerHTML = "EXPIRED"; - } +// Get today's date and time +var now = new Date().getTime(); + +// Find the distance between now and the count down date +var distance = countDownDate - now; + +// Time calculations for days, hours, minutes and seconds +var days = Math.floor(distance / (1000 * 60 * 60 * 24)); +var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); +var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); +var seconds = Math.floor((distance % (1000 * 60)) / 1000); + +// Display the result in the element with id="demo" +document.getElementById("demo").innerHTML = hours + "h " ++ minutes + "m " + seconds + "s "; + +// If the count down is finished, write some text +if (distance < 0) { +clearInterval(x); +document.getElementById("demo").innerHTML = "EXPIRED"; +} }, 1000); --> Padel - {{ match.title }} - COURS {{ match.court }} - + -
-{% if match %} -
- -

COURS {{ match.court }}

- -

{{ match.title }}

- - {% if match.team3 %} - - - - {% if match.team1scorecolumn1 %}{% endif %} - - - {% if match.team1scorecolumn2 %}{% endif %} - - - {% if match.team1scorecolumn3 %}{% endif %} - - - {% if match.team1scorecolumn4 %}{% endif %} - - - - {% if match.team1scorecolumn5 %}{% endif %} - -
{{ match.team1 }}{{ match.team1scorecolumn1 }}
{{ match.team2 }}{{ match.team1scorecolumn2 }}
{{ match.team3 }}{{ match.team1scorecolumn3 }}
{{ match.team4 }}{{ match.team1scorecolumn4 }}
{{ match.team5 }}{{ match.team1scorecolumn5 }}
+
+ + {% if match.club.header %} +
{{ match.club.header }}
+ {% endif %} + +
+ +
+ {% if match %} +
+ +

COURS {{ match.court }}

+ +

{{ match.title }}

+ + {% if match.team3 %} + + + + {% if match.team1scorecolumn1 %}{% endif %} + + + {% if match.team1scorecolumn2 %}{% endif %} + + + {% if match.team1scorecolumn3 %}{% endif %} + + + {% if match.team1scorecolumn4 %}{% endif %} + + + + {% if match.team1scorecolumn5 %}{% endif %} + +
{{ match.team1 }}{{ match.team1scorecolumn1 }}
{{ match.team2 }}{{ match.team1scorecolumn2 }}
{{ match.team3 }}{{ match.team1scorecolumn3 }}
{{ match.team4 }}{{ match.team1scorecolumn4 }}
{{ match.team5 }}{{ match.team1scorecolumn5 }}
+ {% else %} + + + + + {% if match.team1scorecolumn1 %}{% endif %} + {% if match.team1scorecolumn2 %}{% endif %} + {% if match.team1scorecolumn3 %}{% endif %} + {% if match.team1scorecolumn4 %}{% endif %} + {% if match.team1scorecolumn5 %}{% endif %} + + + + {% if match.team2scorecolumn1 %}{% endif %} + {% if match.team2scorecolumn2 %}{% endif %} + {% if match.team2scorecolumn3 %}{% endif %} + {% if match.team2scorecolumn4 %}{% endif %} + {% if match.team2scorecolumn5 %}{% endif %} + +
{{ match.team1 }}{{ match.team1scorecolumn1 }}{{ match.team1scorecolumn2 }}{{ match.team1scorecolumn3 }}{{ match.team1scorecolumn4 }}{{ match.team1scorecolumn5 }}
{{ match.team2 }}{{ match.team2scorecolumn1 }}{{ match.team2scorecolumn2 }}{{ match.team2scorecolumn3 }}{{ match.team2scorecolumn4 }}{{ match.team2scorecolumn5 }}
+ + {% endif %} + +

{{ match.duration }}

+ +
{% else %} - - - - - {% if match.team1scorecolumn1 %}{% endif %} - {% if match.team1scorecolumn2 %}{% endif %} - {% if match.team1scorecolumn3 %}{% endif %} - {% if match.team1scorecolumn4 %}{% endif %} - {% if match.team1scorecolumn5 %}{% endif %} - - - - {% if match.team2scorecolumn1 %}{% endif %} - {% if match.team2scorecolumn2 %}{% endif %} - {% if match.team2scorecolumn3 %}{% endif %} - {% if match.team2scorecolumn4 %}{% endif %} - {% if match.team2scorecolumn5 %}{% endif %} - -
{{ match.team1 }}{{ match.team1scorecolumn1 }}{{ match.team1scorecolumn2 }}{{ match.team1scorecolumn3 }}{{ match.team1scorecolumn4 }}{{ match.team1scorecolumn5 }}
{{ match.team2 }}{{ match.team2scorecolumn1 }}{{ match.team2scorecolumn2 }}{{ match.team2scorecolumn3 }}{{ match.team2scorecolumn4 }}{{ match.team2scorecolumn5 }}
- +

No matches at the moment...

{% endif %} +
-

{{ match.duration }}

+
-
-{% else %} -

No matches at the moment...

-{% endif %} -
+ {% if match.club.footer %} + + {% endif %} - + diff --git a/scores/views.py b/scores/views.py index eb97335..de8ee73 100644 --- a/scores/views.py +++ b/scores/views.py @@ -2,15 +2,17 @@ from django.shortcuts import render, get_object_or_404 from django.http import HttpResponse from django.template import loader from django.contrib.auth.models import User -from .models import Match +from .models import Match, Club from .serializers import UserSerializer, MatchSerializer from rest_framework import viewsets from rest_framework import permissions def index(request): + club = Club.objects.first() matches = Match.objects.order_by('court') template = loader.get_template('scores/index.html') context = { + 'club': club, 'matches': matches, } return HttpResponse(template.render(context, request))