diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..bf31fb1 Binary files /dev/null and b/.DS_Store differ diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..3f39c46 --- /dev/null +++ b/manage.py @@ -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() diff --git a/padel/__init__.py b/padel/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/padel/asgi.py b/padel/asgi.py new file mode 100644 index 0000000..f8e2f14 --- /dev/null +++ b/padel/asgi.py @@ -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() diff --git a/padel/settings.py b/padel/settings.py new file mode 100644 index 0000000..fdddac8 --- /dev/null +++ b/padel/settings.py @@ -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' diff --git a/padel/urls.py b/padel/urls.py new file mode 100644 index 0000000..6d79dd2 --- /dev/null +++ b/padel/urls.py @@ -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), +] diff --git a/padel/wsgi.py b/padel/wsgi.py new file mode 100644 index 0000000..90b2d24 --- /dev/null +++ b/padel/wsgi.py @@ -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() diff --git a/scores/.DS_Store b/scores/.DS_Store new file mode 100644 index 0000000..6ab2276 Binary files /dev/null and b/scores/.DS_Store differ diff --git a/scores/__init__.py b/scores/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scores/admin.py b/scores/admin.py new file mode 100644 index 0000000..db3ab4e --- /dev/null +++ b/scores/admin.py @@ -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) diff --git a/scores/apps.py b/scores/apps.py new file mode 100644 index 0000000..14a148d --- /dev/null +++ b/scores/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ScoresConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'scores' diff --git a/scores/migrations/0001_initial.py b/scores/migrations/0001_initial.py new file mode 100644 index 0000000..19014aa --- /dev/null +++ b/scores/migrations/0001_initial.py @@ -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')), + ], + ), + ] diff --git a/scores/migrations/0002_match_team2scorecolumn5.py b/scores/migrations/0002_match_team2scorecolumn5.py new file mode 100644 index 0000000..d1331d8 --- /dev/null +++ b/scores/migrations/0002_match_team2scorecolumn5.py @@ -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, + ), + ] diff --git a/scores/migrations/0003_alter_match_team1_alter_match_team1scorecolumn1_and_more.py b/scores/migrations/0003_alter_match_team1_alter_match_team1scorecolumn1_and_more.py new file mode 100644 index 0000000..0b96695 --- /dev/null +++ b/scores/migrations/0003_alter_match_team1_alter_match_team1scorecolumn1_and_more.py @@ -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), + ), + ] diff --git a/scores/migrations/0004_match_court.py b/scores/migrations/0004_match_court.py new file mode 100644 index 0000000..c3cebd4 --- /dev/null +++ b/scores/migrations/0004_match_court.py @@ -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), + ), + ] diff --git a/scores/migrations/__init__.py b/scores/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scores/models.py b/scores/models.py new file mode 100644 index 0000000..039a9ca --- /dev/null +++ b/scores/models.py @@ -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)) diff --git a/scores/static/.DS_Store b/scores/static/.DS_Store new file mode 100644 index 0000000..2e86add Binary files /dev/null and b/scores/static/.DS_Store differ diff --git a/scores/static/scores/style.css b/scores/static/scores/style.css new file mode 100644 index 0000000..f34f9a2 --- /dev/null +++ b/scores/static/scores/style.css @@ -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; */ +} diff --git a/scores/templates/.DS_Store b/scores/templates/.DS_Store new file mode 100644 index 0000000..b3d21f9 Binary files /dev/null and b/scores/templates/.DS_Store differ diff --git a/scores/templates/scores/index.html b/scores/templates/scores/index.html new file mode 100644 index 0000000..d2ba35a --- /dev/null +++ b/scores/templates/scores/index.html @@ -0,0 +1,80 @@ +{% load static %} + + + + + + Padel kikou + + + + + +
+{% if matches %} +
+ {% for match in matches %} +

Cours #{{ match.court }} - {{ match.title }}

+ +

{{ match.duration }}

+ + + + + {% 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 }}
+ + {% endfor %} +
+ +{% else %} +

No matches at the moment...

+{% endif %} +
+ + + + + diff --git a/scores/tests.py b/scores/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/scores/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/scores/urls.py b/scores/urls.py new file mode 100644 index 0000000..0bc9ea4 --- /dev/null +++ b/scores/urls.py @@ -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'), +] diff --git a/scores/views.py b/scores/views.py new file mode 100644 index 0000000..c8d7389 --- /dev/null +++ b/scores/views.py @@ -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))