first commit

v2
Laurent 3 years ago
parent f9ae004496
commit fa014aa11d
  1. BIN
      .DS_Store
  2. 22
      manage.py
  3. 0
      padel/__init__.py
  4. 16
      padel/asgi.py
  5. 124
      padel/settings.py
  6. 22
      padel/urls.py
  7. 16
      padel/wsgi.py
  8. BIN
      scores/.DS_Store
  9. 0
      scores/__init__.py
  10. 8
      scores/admin.py
  11. 6
      scores/apps.py
  12. 44
      scores/migrations/0001_initial.py
  13. 19
      scores/migrations/0002_match_team2scorecolumn5.py
  14. 88
      scores/migrations/0003_alter_match_team1_alter_match_team1scorecolumn1_and_more.py
  15. 18
      scores/migrations/0004_match_court.py
  16. 0
      scores/migrations/__init__.py
  17. 35
      scores/models.py
  18. BIN
      scores/static/.DS_Store
  19. 41
      scores/static/scores/style.css
  20. BIN
      scores/templates/.DS_Store
  21. 80
      scores/templates/scores/index.html
  22. 3
      scores/tests.py
  23. 23
      scores/urls.py
  24. 12
      scores/views.py

BIN
.DS_Store vendored

Binary file not shown.

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'padel.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

@ -0,0 +1,16 @@
"""
ASGI config for padel project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'padel.settings')
application = get_asgi_application()

@ -0,0 +1,124 @@
"""
Django settings for padel project.
Generated by 'django-admin startproject' using Django 4.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-y6eq)a5r)((id1vtb_be!nco92vla2$#iwm^^opa7@x4(%o5mh'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'scores'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'padel.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'padel.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

@ -0,0 +1,22 @@
"""padel URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('scores.urls')),
path('admin/', admin.site.urls),
]

@ -0,0 +1,16 @@
"""
WSGI config for padel project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'padel.settings')
application = get_wsgi_application()

BIN
scores/.DS_Store vendored

Binary file not shown.

@ -0,0 +1,8 @@
from django.contrib import admin
# Register your models here.
from .models import Club
from .models import Match
admin.site.register(Club)
admin.site.register(Match)

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ScoresConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'scores'

@ -0,0 +1,44 @@
# Generated by Django 4.1.1 on 2023-02-22 16:36
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Club',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
],
),
migrations.CreateModel(
name='Match',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateTimeField(verbose_name='start date')),
('title', models.CharField(max_length=200)),
('team1', models.CharField(max_length=200)),
('team2', models.CharField(max_length=200)),
('team3', models.CharField(max_length=200)),
('team4', models.CharField(max_length=200)),
('team1scorecolumn1', models.CharField(max_length=200)),
('team1scorecolumn2', models.CharField(max_length=200)),
('team1scorecolumn3', models.CharField(max_length=200)),
('team1scorecolumn4', models.CharField(max_length=200)),
('team2scorecolumn1', models.CharField(max_length=200)),
('team2scorecolumn2', models.CharField(max_length=200)),
('team2scorecolumn3', models.CharField(max_length=200)),
('team2scorecolumn4', models.CharField(max_length=200)),
('team1scorecolumn5', models.CharField(max_length=200)),
('club', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scores.club')),
],
),
]

@ -0,0 +1,19 @@
# Generated by Django 4.1.1 on 2023-02-22 16:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('scores', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='match',
name='team2scorecolumn5',
field=models.CharField(default=0, max_length=200),
preserve_default=False,
),
]

@ -0,0 +1,88 @@
# Generated by Django 4.1.1 on 2023-02-22 16:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('scores', '0002_match_team2scorecolumn5'),
]
operations = [
migrations.AlterField(
model_name='match',
name='team1',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team1scorecolumn1',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team1scorecolumn2',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team1scorecolumn3',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team1scorecolumn4',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team1scorecolumn5',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team2',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team2scorecolumn1',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team2scorecolumn2',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team2scorecolumn3',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team2scorecolumn4',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team2scorecolumn5',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team3',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='team4',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='match',
name='title',
field=models.CharField(blank=True, max_length=200),
),
]

@ -0,0 +1,18 @@
# Generated by Django 4.1.1 on 2023-02-22 16:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('scores', '0003_alter_match_team1_alter_match_team1scorecolumn1_and_more'),
]
operations = [
migrations.AddField(
model_name='match',
name='court',
field=models.IntegerField(default=0),
),
]

@ -0,0 +1,35 @@
from django.db import models
import datetime
from datetime import timedelta
class Club(models.Model):
name = models.CharField(max_length=200)
def __str__(self):
return self.name
class Match(models.Model):
club = models.ForeignKey(Club, on_delete=models.CASCADE)
date = models.DateTimeField('start date')
court = models.IntegerField(default=0)
title = models.CharField(max_length=200, blank=True)
team1 = models.CharField(max_length=200, blank=True)
team2 = models.CharField(max_length=200, blank=True)
team3 = models.CharField(max_length=200, blank=True)
team4 = models.CharField(max_length=200, blank=True)
team1scorecolumn1 = models.CharField(max_length=200, blank=True)
team1scorecolumn2 = models.CharField(max_length=200, blank=True)
team1scorecolumn3 = models.CharField(max_length=200, blank=True)
team1scorecolumn4 = models.CharField(max_length=200, blank=True)
team1scorecolumn5 = models.CharField(max_length=200, blank=True)
team2scorecolumn1 = models.CharField(max_length=200, blank=True)
team2scorecolumn2 = models.CharField(max_length=200, blank=True)
team2scorecolumn3 = models.CharField(max_length=200, blank=True)
team2scorecolumn4 = models.CharField(max_length=200, blank=True)
team2scorecolumn5 = models.CharField(max_length=200, blank=True)
# def duration(self):
# delta = datetime.now().date() - date
# return str(timedelta(delta))

Binary file not shown.

@ -0,0 +1,41 @@
a {
color: white;
}
html {
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 */
background-color: #438FFF;
color: white;
}
table {
font-size: 40px; /* px signifie 'pixels': la taille de base pour la police est désormais 10 pixels de haut */
font-weight: 600;
}
table, th, td {
border: 1px solid;
border-color: white;
border-collapse: collapse;
}
td {
padding: 10px;
}
.score {
width: 50px;
text-align: center;
vertical-align: middle;
}
.match {
/* display: inline-block; */
/* background-color: red; */
}
.container {
/* width: 100%; */
/* margin: 0 auto; */
}

Binary file not shown.

@ -0,0 +1,80 @@
{% load static %}
<html>
<head>
<link rel="stylesheet" href="{% static 'scores/style.css' %}">
<title>Padel kikou</title>
<!-- <meta http-equiv="refresh" content="5" > -->
</head>
<!-- <p id="demo"></p> -->
<div class="container">
{% if matches %}
<div class="match">
{% for match in matches %}
<h1><a href="/scores/{{ match.id }}/">Cours #{{ match.court }} - {{ match.title }}</a></h1>
<h3>{{ match.duration }}</h3>
<table>
<tr>
<td>{{ match.team1 }}</td>
{% if match.team1scorecolumn1 %}<td class="score">{{ match.team1scorecolumn1 }}</td>{% endif %}
{% if match.team1scorecolumn2 %}<td class="score">{{ match.team1scorecolumn2 }}</td>{% endif %}
{% if match.team1scorecolumn3 %}<td class="score">{{ match.team1scorecolumn3 }}</td>{% endif %}
{% if match.team1scorecolumn4 %}<td class="score">{{ match.team1scorecolumn4 }}</td>{% endif %}
{% if match.team1scorecolumn5 %}<td class="score">{{ match.team1scorecolumn5 }}</td>{% endif %}
</tr>
<tr>
<td>{{ match.team2 }}</td>
{% if match.team2scorecolumn1 %}<td class="score">{{ match.team2scorecolumn1 }}</td>{% endif %}
{% if match.team2scorecolumn2 %}<td class="score">{{ match.team2scorecolumn2 }}</td>{% endif %}
{% if match.team2scorecolumn3 %}<td class="score">{{ match.team2scorecolumn3 }}</td>{% endif %}
{% if match.team2scorecolumn4 %}<td class="score">{{ match.team2scorecolumn4 }}</td>{% endif %}
{% if match.team2scorecolumn5 %}<td class="score">{{ match.team2scorecolumn5 }}</td>{% endif %}
</tr>
</table>
{% endfor %}
</div>
{% else %}
<p>No matches at the moment...</p>
{% endif %}
</div>
<script>
// Set the date we're counting down to
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";
}
}, 1000);
</script>
</html>

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

@ -0,0 +1,23 @@
"""padel URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]

@ -0,0 +1,12 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from .models import Match
def index(request):
matches = Match.objects.order_by('-court')
template = loader.get_template('scores/index.html')
context = {
'matches': matches,
}
return HttpResponse(template.render(context, request))
Loading…
Cancel
Save