From e3eb42429050e048e2c6f41a3939b104eb4726af Mon Sep 17 00:00:00 2001 From: Etienne GILLE Date: Fri, 13 Feb 2026 16:04:01 +0100 Subject: [PATCH] =?UTF-8?q?Mod=C3=A9lisation=20de=20donn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + Dockerfile | 21 ++++ compterendu/__init__.py | 0 compterendu/admin.py | 3 + compterendu/apps.py | 5 + compterendu/migrations/0001_initial.py | 86 +++++++++++++++ compterendu/migrations/__init__.py | 0 compterendu/models.py | 75 +++++++++++++ compterendu/tests.py | 3 + compterendu/views.py | 3 + docker-compose.yml | 33 ++++++ manage.py | 22 ++++ package.json | 9 ++ requirements.txt | 5 + reunion/__init__.py | 0 reunion/asgi.py | 16 +++ reunion/settings.py | 145 +++++++++++++++++++++++++ reunion/urls.py | 24 ++++ reunion/wsgi.py | 16 +++ 19 files changed, 468 insertions(+) create mode 100644 Dockerfile create mode 100644 compterendu/__init__.py create mode 100644 compterendu/admin.py create mode 100644 compterendu/apps.py create mode 100644 compterendu/migrations/0001_initial.py create mode 100644 compterendu/migrations/__init__.py create mode 100644 compterendu/models.py create mode 100644 compterendu/tests.py create mode 100644 compterendu/views.py create mode 100644 docker-compose.yml create mode 100644 manage.py create mode 100644 package.json create mode 100644 requirements.txt create mode 100644 reunion/__init__.py create mode 100644 reunion/asgi.py create mode 100644 reunion/settings.py create mode 100644 reunion/urls.py create mode 100644 reunion/wsgi.py diff --git a/.gitignore b/.gitignore index 36b13f1..d554c5f 100644 --- a/.gitignore +++ b/.gitignore @@ -174,3 +174,5 @@ cython_debug/ # PyPI configuration file .pypirc +# Custom +static/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..710c8c6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Build +FROM python:3.14 as build +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 +WORKDIR /usr/src/app +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt +COPY . . +RUN apt-get --no-cache install npm +RUN python ./manage.py collectstatic +RUN rm -rf node_modules + +# Run +FROM python:3.14-slim +WORKDIR /usr/src/app +COPY --from=build /usr/local/lib/python3.14/site-packages/ /usr/local/lib/python3.13/site-packages/ + +COPY --from=build /usr/src/app . +EXPOSE 8000 + +CMD [ "gunicorn", "reunion.wsgi"] \ No newline at end of file diff --git a/compterendu/__init__.py b/compterendu/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/compterendu/admin.py b/compterendu/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/compterendu/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/compterendu/apps.py b/compterendu/apps.py new file mode 100644 index 0000000..91516c0 --- /dev/null +++ b/compterendu/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class CompterenduConfig(AppConfig): + name = 'compterendu' diff --git a/compterendu/migrations/0001_initial.py b/compterendu/migrations/0001_initial.py new file mode 100644 index 0000000..21d2bb1 --- /dev/null +++ b/compterendu/migrations/0001_initial.py @@ -0,0 +1,86 @@ +# Generated by Django 6.0.2 on 2026-02-13 15:03 + +import django.db.models.deletion +import djrichtextfield.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Assemblee', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nom', models.CharField(max_length=255)), + ], + ), + migrations.CreateModel( + name='PointOrdreDuJour', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('ordre', models.PositiveSmallIntegerField()), + ('titre', models.CharField(max_length=512)), + ('texte', djrichtextfield.models.RichTextField()), + ], + options={ + 'ordering': ['reunion', 'ordre'], + }, + ), + migrations.CreateModel( + name='PostesBureau', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nom', models.CharField(max_length=255)), + ], + ), + migrations.CreateModel( + name='DiscussionPointOrdreDuJour', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('texte', djrichtextfield.models.RichTextField()), + ('point', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='compterendu.pointordredujour')), + ], + ), + migrations.CreateModel( + name='MembreAssemblee', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nom', models.CharField(max_length=255)), + ('prenom', models.CharField(max_length=255)), + ('assemblee', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='membres', to='compterendu.assemblee')), + ('poste_bureau', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='compterendu.postesbureau')), + ], + ), + migrations.CreateModel( + name='Reunion', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nom', models.CharField(max_length=255)), + ('debut', models.DateTimeField()), + ('assemblee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reunions', to='compterendu.assemblee')), + ], + options={ + 'ordering': ['assemblee', 'debut'], + }, + ), + migrations.CreateModel( + name='PresenceReunion', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('presence', models.PositiveSmallIntegerField(choices=[(1, 'Présent'), (2, 'Excusé'), (3, 'Absent')])), + ('membre', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='presences_reunions', to='compterendu.reunion')), + ('reunion', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='presences', to='compterendu.reunion')), + ], + ), + migrations.AddField( + model_name='pointordredujour', + name='reunion', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='points_ordre_du_jour', to='compterendu.reunion'), + ), + ] diff --git a/compterendu/migrations/__init__.py b/compterendu/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/compterendu/models.py b/compterendu/models.py new file mode 100644 index 0000000..cdc9d28 --- /dev/null +++ b/compterendu/models.py @@ -0,0 +1,75 @@ +from django.db import models +from djrichtextfield.models import RichTextField + +# Create your models here. + +class PostesBureau(models.Model): + nom = models.CharField(max_length=255) + + def __str__(self): + return self.nom + +class Assemblee(models.Model): + nom = models.CharField(max_length=255) + + def __str__(self): + return self.name + + +class MembreAssemblee(models.Model): + nom = models.CharField(max_length=255) + prenom = models.CharField(max_length=255) + assemblee = models.ForeignKey(Assemblee, on_delete=models.PROTECT, related_name="membres") + poste_bureau = models.ForeignKey(PostesBureau, on_delete=models.SET_NULL, blank=True, null=True, related_name="+") + + @property + def est_au_bureau(self): + return self.poste_bureau is not None + + def __str__(self): + return f"{self.prenom} {self.prenom} - {self.assemblee}" + + +class Reunion(models.Model): + nom = models.CharField(max_length=255) + debut = models.DateTimeField() + assemblee = models.ForeignKey(Assemblee, on_delete=models.CASCADE, related_name="reunions") + + def __str__(self): + return f"{self.nom} de {self.assemblee} - {self.debut}" + + class Meta: + ordering = ['assemblee', 'debut'] + + +class PresenceReunion(models.Model): + class TypePresence(models.IntegerChoices): + PRESENT = 1, "Présent" + EXCUSE = 2, "Excusé" + ABSENT = 3, "Absent" + reunion = models.ForeignKey(Reunion, on_delete=models.CASCADE, related_name="presences") + membre = models.ForeignKey(Reunion, on_delete=models.CASCADE, related_name="presences_reunions") + presence = models.PositiveSmallIntegerField(choices=TypePresence) + + def __str__(self): + return f"{self.membre} - {self.reunion} - {self.presence.label}" + + +class PointOrdreDuJour(models.Model): + reunion = models.ForeignKey(Reunion, on_delete=models.CASCADE, related_name="points_ordre_du_jour") + ordre = models.PositiveSmallIntegerField() + titre = models.CharField(max_length=512) + texte = RichTextField() + + def __str__(self): + return f'{self.reunion} - {self.titre}' + + class Meta: + ordering = ['reunion', 'ordre'] + +class DiscussionPointOrdreDuJour(models.Model): + point = models.OneToOneField(PointOrdreDuJour, on_delete=models.PROTECT) + texte = RichTextField() + + def __str__(self): + return self.point \ No newline at end of file diff --git a/compterendu/tests.py b/compterendu/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/compterendu/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/compterendu/views.py b/compterendu/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/compterendu/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f53194d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +services: + app: + build: . + volume: + - static:/usr/src/app/static + - media:/usr/src/app/media + env_file: .env + proxy: + image: nginx:latest + volume: + - type: volume + source: static + target: /usr/share/nginx/html/static + read-only: true + volume: + nocopy: true + - type: volume + source: media + target: /usr/share/nginx/html/media + read-only: true + volume: + nocopy: true + ports: + - "8080:80" + db: + image: mysql + volume: + - mysql_db:/var/lib/mysql + env_file: .env +volumes: + static: + media: + mysql_db: \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..547f056 --- /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', 'reunion.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/package.json b/package.json new file mode 100644 index 0000000..eb0929a --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "reunion", + "version": "0.0.0", + "dependencies": { + "bootstrap": "5.3.*", + "htmx.org": "2.0.*", + "tinymce": "8.2.*" + } +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b978e27 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +Django~=6.0.2 +daphne~=4.2.1 +django-node-assets~=0.9.15 +python-docx~=1.2.0 +django-richtextfield~=1.6.2 \ No newline at end of file diff --git a/reunion/__init__.py b/reunion/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/reunion/asgi.py b/reunion/asgi.py new file mode 100644 index 0000000..c53074f --- /dev/null +++ b/reunion/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for reunion 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/6.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'reunion.settings') + +application = get_asgi_application() diff --git a/reunion/settings.py b/reunion/settings.py new file mode 100644 index 0000000..080b74a --- /dev/null +++ b/reunion/settings.py @@ -0,0 +1,145 @@ +""" +Django settings for reunion project. + +Generated by 'django-admin startproject' using Django 6.0.2. + +For more information on this file, see +https://docs.djangoproject.com/en/6.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/6.0/ref/settings/ +""" + +from pathlib import Path +import os + +# 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/6.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.environ.get("SECRET_KEY") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = bool(os.environ.get("DEBUG", default=0)) + +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOW_HOSTS","127.0.0.1").split(",") + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django_node_assets', + 'compterendu', + 'djrichtextfield' +] + +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 = 'reunion.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ BASE_DIR / 'templates'], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'reunion.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/6.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/6.0/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/6.0/topics/i18n/ + +LANGUAGE_CODE = 'fr-fr' + +TIME_ZONE = 'Europe/Paris' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/6.0/howto/static-files/ + +STATICFILES_FINDERS = [ + "django.contrib.staticfiles.finders.FileSystemFinder", + "django.contrib.staticfiles.finders.AppDirectoriesFinder", + "django_node_assets.finders.NodeModulesFinder", +] +STATIC_URL = 'static/' +STATIC_ROOT = BASE_DIR / "static" + +MEDIA_URL = 'media/' +MEDIA_ROOT = BASE_DIR / "media" + +#Node Modules +NODE_MODULES_ROOT = BASE_DIR / "node_modules" + +# Django RichTextField +DJRICHTEXT_CONFIG = { + 'js': ['tinymce/tinymce.min.js'], + 'init_template': 'djrichtextfield/init/tinymce.js', + 'settings': { + 'menubar': False, + 'plugins': 'link image', + 'toolbar': 'bold italic | link image | removeformat', + 'width': 700 + } +} \ No newline at end of file diff --git a/reunion/urls.py b/reunion/urls.py new file mode 100644 index 0000000..869e747 --- /dev/null +++ b/reunion/urls.py @@ -0,0 +1,24 @@ +""" +URL configuration for reunion project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/6.0/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, include + +urlpatterns = [ + #path('', include('compterendu.urls')), + path('admin/', admin.site.urls), + path('djrichtextfield/', include('djrichtextfield.urls')) +] diff --git a/reunion/wsgi.py b/reunion/wsgi.py new file mode 100644 index 0000000..cab5d4a --- /dev/null +++ b/reunion/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for reunion 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/6.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'reunion.settings') + +application = get_wsgi_application()