Added header/footer and improved UI

v2
Laurent 3 years ago
parent 90c18edf05
commit fe15928374
  1. 23
      scores/migrations/0006_club_footer_club_header.py
  2. 2
      scores/models.py
  3. 40
      scores/static/scores/style.css
  4. 72
      scores/templates/scores/index.html
  5. 72
      scores/templates/scores/match.html
  6. 4
      scores/views.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),
),
]

@ -3,6 +3,8 @@ from django.utils import timezone
class Club(models.Model): class Club(models.Model):
name = models.CharField(max_length=200) 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): def __str__(self):
return self.name return self.name

@ -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-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: 'Open Sans', sans-serif; /* cela devrait être le reste du résultat obtenu à partir de Google fonts */
font-family: Helvetica, sans-serif; font-family: Helvetica, sans-serif;
background-color: #3878D8; background-color: #3878D8;
color: white; 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 { a {
@ -13,7 +38,7 @@ a {
} }
table { 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; font-weight: 600;
} }
@ -31,6 +56,10 @@ td {
padding: 10px; padding: 10px;
} }
.big {
font-size: 30px;
}
.score { .score {
width: 60px; width: 60px;
text-align: center; text-align: center;
@ -50,7 +79,7 @@ td {
} }
.smatch { .smatch {
padding-top: 100px; padding-top: 50px;
width: 800px; width: 800px;
margin: 0 auto; margin: 0 auto;
@ -67,7 +96,10 @@ td {
align-items: center; align-items: center;
} }
.page-footer {
flex-grow: 0;
flex-shrink: 0;
}
.container { .container {
/* width: 100%; */ /* width: 100%; */
/* text-align:center; */ /* text-align:center; */

@ -9,40 +9,47 @@ var countDownDate = new Date("Jan 5, 2024 15:37:25").getTime();
// Update the count down every 1 second // Update the count down every 1 second
var x = setInterval(function() { var x = setInterval(function() {
// Get today's date and time // Get today's date and time
var now = new Date().getTime(); var now = new Date().getTime();
// Find the distance between now and the count down date // Find the distance between now and the count down date
var distance = {{ match.seconds }} * -1; var distance = {{ match.seconds }} * -1;
// Time calculations for days, hours, minutes and seconds // Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000); var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo" // Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = hours + "h " document.getElementById("demo").innerHTML = hours + "h "
+ minutes + "m " + seconds + "s "; + minutes + "m " + seconds + "s ";
// If the count down is finished, write some text // If the count down is finished, write some text
if (distance < 0) { if (distance < 0) {
clearInterval(x); clearInterval(x);
document.getElementById("demo").innerHTML = "Démarrage en cours..."; document.getElementById("demo").innerHTML = "Démarrage en cours...";
} }
}, 1000); }, 1000);
</script> --> </script> -->
<head> <head>
<link rel="stylesheet" href="{% static 'scores/style.css' %}"> <link rel="stylesheet" href="{% static 'scores/style.css' %}">
<title>Padel</title> <title>Padel</title>
<!-- <meta http-equiv="refresh" content="5" > --> <meta http-equiv="refresh" content="15"/>
</head> </head>
<div class="wrapper">
<div class="container"> {% if club.header %}
{% if matches %} <header class="center">{{ club.header }}</header>
{% for match in matches %} {% endif %}
<main class="page-body">
<div class="container">
{% if matches %}
{% for match in matches %}
<div class="match"> <div class="match">
<p><a href="/match/{{ match.id }}/">COURS #{{ match.court }}</a></p> <p><a href="/match/{{ match.id }}/">COURS #{{ match.court }}</a></p>
@ -94,15 +101,22 @@ var x = setInterval(function() {
<!-- <p id="demo"></p> --> <!-- <p id="demo"></p> -->
<p>{{ match.duration }}</p> <p class="big">{{ match.duration }}</p>
</div> </div>
{% endfor %} {% endfor %}
{% else %} {% else %}
<p class="center">Pas de matchs en cours...</p> <p class="center">Pas de matchs en cours...</p>
{% endif %} {% endif %}
</div> </div>
</main>
{% if club.footer %}
<footer class="page-footer, center">{{ club.footer }}</footer>
{% endif %}
</div>
</html> </html>

@ -9,40 +9,48 @@ var countDownDate = new Date("Jan 5, 2024 15:37:25").getTime();
// Update the count down every 1 second // Update the count down every 1 second
var x = setInterval(function() { var x = setInterval(function() {
// Get today's date and time // Get today's date and time
var now = new Date().getTime(); var now = new Date().getTime();
// Find the distance between now and the count down date // Find the distance between now and the count down date
var distance = countDownDate - now; var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds // Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000); var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo" // Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = hours + "h " document.getElementById("demo").innerHTML = hours + "h "
+ minutes + "m " + seconds + "s "; + minutes + "m " + seconds + "s ";
// If the count down is finished, write some text // If the count down is finished, write some text
if (distance < 0) { if (distance < 0) {
clearInterval(x); clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED"; document.getElementById("demo").innerHTML = "EXPIRED";
} }
}, 1000); }, 1000);
</script> --> </script> -->
<head> <head>
<link rel="stylesheet" href="{% static 'scores/style.css' %}"> <link rel="stylesheet" href="{% static 'scores/style.css' %}">
<title>Padel - {{ match.title }} - COURS {{ match.court }}</title> <title>Padel - {{ match.title }} - COURS {{ match.court }}</title>
<!-- <meta http-equiv="refresh" content="5" > --> <meta http-equiv="refresh" content="15"/>
</head> </head>
<!-- <p id="demo"></p> --> <!-- <p id="demo"></p> -->
<div class="scontainer"> <div class="wrapper">
{% if match %}
{% if match.club.header %}
<header class="center">{{ match.club.header }}</header>
{% endif %}
<main class="page-body">
<div class="scontainer">
{% if match %}
<div class="smatch"> <div class="smatch">
<p>COURS {{ match.court }}</p> <p>COURS {{ match.court }}</p>
@ -92,13 +100,19 @@ var x = setInterval(function() {
{% endif %} {% endif %}
<p>{{ match.duration }}</p> <p class="big">{{ match.duration }}</p>
</div> </div>
{% else %} {% else %}
<p class="center">No matches at the moment...</p> <p class="center">No matches at the moment...</p>
{% endif %} {% endif %}
</div> </div>
</main>
{% if match.club.footer %}
<footer class="page-footer, center">{{ match.club.footer }}</footer>
{% endif %}
</html> </html>

@ -2,15 +2,17 @@ from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse from django.http import HttpResponse
from django.template import loader from django.template import loader
from django.contrib.auth.models import User from django.contrib.auth.models import User
from .models import Match from .models import Match, Club
from .serializers import UserSerializer, MatchSerializer from .serializers import UserSerializer, MatchSerializer
from rest_framework import viewsets from rest_framework import viewsets
from rest_framework import permissions from rest_framework import permissions
def index(request): def index(request):
club = Club.objects.first()
matches = Match.objects.order_by('court') matches = Match.objects.order_by('court')
template = loader.get_template('scores/index.html') template = loader.get_template('scores/index.html')
context = { context = {
'club': club,
'matches': matches, 'matches': matches,
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))

Loading…
Cancel
Save