Modélisation de données
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -174,3 +174,5 @@ cython_debug/
|
||||
# PyPI configuration file
|
||||
.pypirc
|
||||
|
||||
# Custom
|
||||
static/*
|
||||
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@@ -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"]
|
||||
0
compterendu/__init__.py
Normal file
0
compterendu/__init__.py
Normal file
3
compterendu/admin.py
Normal file
3
compterendu/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
5
compterendu/apps.py
Normal file
5
compterendu/apps.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CompterenduConfig(AppConfig):
|
||||
name = 'compterendu'
|
||||
86
compterendu/migrations/0001_initial.py
Normal file
86
compterendu/migrations/0001_initial.py
Normal file
@@ -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'),
|
||||
),
|
||||
]
|
||||
0
compterendu/migrations/__init__.py
Normal file
0
compterendu/migrations/__init__.py
Normal file
75
compterendu/models.py
Normal file
75
compterendu/models.py
Normal file
@@ -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
|
||||
3
compterendu/tests.py
Normal file
3
compterendu/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
compterendu/views.py
Normal file
3
compterendu/views.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
33
docker-compose.yml
Normal file
33
docker-compose.yml
Normal file
@@ -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:
|
||||
22
manage.py
Normal file
22
manage.py
Normal file
@@ -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()
|
||||
9
package.json
Normal file
9
package.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "reunion",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"bootstrap": "5.3.*",
|
||||
"htmx.org": "2.0.*",
|
||||
"tinymce": "8.2.*"
|
||||
}
|
||||
}
|
||||
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@@ -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
|
||||
0
reunion/__init__.py
Normal file
0
reunion/__init__.py
Normal file
16
reunion/asgi.py
Normal file
16
reunion/asgi.py
Normal file
@@ -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()
|
||||
145
reunion/settings.py
Normal file
145
reunion/settings.py
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
24
reunion/urls.py
Normal file
24
reunion/urls.py
Normal file
@@ -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'))
|
||||
]
|
||||
16
reunion/wsgi.py
Normal file
16
reunion/wsgi.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user