8 Commits

20 changed files with 350 additions and 98 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
.env
node_modules/
hardcoded-strings-report.md
backend.env

View File

@ -1 +1 @@
node scripts/prepare-commit-msg.js "$1" "$2"
#node scripts/prepare-commit-msg.js "$1" "$2"

12
Back-End/Auth/tests.py Normal file
View File

@ -0,0 +1,12 @@
from django.test import TestCase
from .models import Profile
class ProfileModelTest(TestCase):
def test_create_profile(self):
user = Profile.objects.create_user(
username="testuser",
email="test@example.com",
password="testpass123"
)
self.assertEqual(user.email, "test@example.com")
self.assertTrue(user.check_password("testpass123"))

View File

@ -1,3 +1,11 @@
from django.test import TestCase
from .models import Domain
# Create your tests here.
class DomainModelTest(TestCase):
def test_create_domain(self):
domain = Domain.objects.create(name="Mathématiques", cycle=1)
self.assertEqual(domain.name, "Mathématiques")
self.assertEqual(domain.cycle, 1)
self.assertIsNotNone(domain.id)

View File

@ -0,0 +1,17 @@
from django.test import TestCase
from .models import Establishment, StructureType, EvaluationFrequency
class EstablishmentModelTest(TestCase):
def test_create_establishment(self):
est = Establishment.objects.create(
name="École Test",
address="1 rue de l'École",
total_capacity=100,
establishment_type=[StructureType.PRIMAIRE],
evaluation_frequency=EvaluationFrequency.TRIMESTER,
licence_code="ABC123"
)
self.assertEqual(est.name, "École Test")
self.assertEqual(est.establishment_type, [StructureType.PRIMAIRE])
self.assertTrue(est.is_active)
self.assertIsNotNone(est.created_at)

View File

@ -0,0 +1,13 @@
from django.test import TestCase
from .models import Conversation
class ConversationModelTest(TestCase):
def test_create_conversation(self):
conv = Conversation.objects.create(
name="Groupe Test",
conversation_type="group"
)
self.assertEqual(conv.name, "Groupe Test")
self.assertEqual(conv.conversation_type, "group")
self.assertTrue(conv.is_active)
self.assertIsNotNone(conv.id)

View File

@ -0,0 +1,22 @@
from django.test import TestCase
from .models import Notification, TypeNotif
from Auth.models import Profile
class NotificationModelTest(TestCase):
def setUp(self):
self.user = Profile.objects.create_user(
username="notifuser",
email="notif@example.com",
password="testpass123"
)
def test_create_notification(self):
notif = Notification.objects.create(
user=self.user,
message="Un message a été reçu",
typeNotification=TypeNotif.NOTIF_MESSAGE
)
self.assertEqual(notif.user, self.user)
self.assertEqual(notif.message, "Un message a été reçu")
self.assertFalse(notif.is_read)
self.assertEqual(notif.typeNotification, TypeNotif.NOTIF_MESSAGE)

View File

@ -0,0 +1,27 @@
from django.test import TestCase
from .models import Planning
from Establishment.models import Establishment
from School.models import SchoolClass
class PlanningModelTest(TestCase):
def setUp(self):
self.establishment = Establishment.objects.create(
name="École Test",
address="1 rue de l'École",
total_capacity=100,
establishment_type=[1],
evaluation_frequency=1,
licence_code="ABC123"
)
self.school_class = SchoolClass.objects.create(
atmosphere_name="Classe Test",
establishment=self.establishment
)
def test_create_planning(self):
planning = Planning.objects.create(
school_class=self.school_class,
establishment=self.establishment
)
self.assertEqual(planning.school_class, self.school_class)
self.assertEqual(planning.establishment, self.establishment)

View File

@ -1,3 +1,77 @@
from django.test import TestCase
from .models import Speciality, Teacher, SchoolClass, Planning, Discount, Fee, PaymentPlan, PaymentMode, Competency, EstablishmentCompetency
from Establishment.models import Establishment
from Common.models import Category, PaymentPlanType, PaymentModeType
from datetime import date
# Create your tests here.
class SpecialityModelTest(TestCase):
def test_create_speciality(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
speciality = Speciality.objects.create(name="Maths", establishment=est)
self.assertEqual(speciality.name, "Maths")
self.assertEqual(speciality.establishment, est)
class TeacherModelTest(TestCase):
def test_create_teacher(self):
teacher = Teacher.objects.create(last_name="Martin", first_name="Paul")
self.assertEqual(teacher.last_name, "Martin")
self.assertEqual(teacher.first_name, "Paul")
class SchoolClassModelTest(TestCase):
def test_create_school_class(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
school_class = SchoolClass.objects.create(atmosphere_name="Classe A", establishment=est)
self.assertEqual(school_class.atmosphere_name, "Classe A")
self.assertEqual(school_class.establishment, est)
class PlanningModelTest(TestCase):
def test_create_planning(self):
school_class = SchoolClass.objects.create(atmosphere_name="Classe B", establishment=Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A"))
planning = Planning.objects.create(school_class=school_class)
self.assertEqual(planning.school_class, school_class)
class DiscountModelTest(TestCase):
def test_create_discount(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
discount = Discount.objects.create(name="Réduction", establishment=est)
self.assertEqual(discount.name, "Réduction")
self.assertEqual(discount.establishment, est)
class FeeModelTest(TestCase):
def test_create_fee(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
fee = Fee.objects.create(name="Frais", establishment=est)
self.assertEqual(fee.name, "Frais")
self.assertEqual(fee.establishment, est)
class PaymentPlanModelTest(TestCase):
def test_create_payment_plan(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
plan_type = PaymentPlanType.objects.create(code="A", label="Plan A")
payment_plan = PaymentPlan.objects.create(plan_type=plan_type, establishment=est)
self.assertEqual(payment_plan.plan_type, plan_type)
self.assertEqual(payment_plan.establishment, est)
class PaymentModeModelTest(TestCase):
def test_create_payment_mode(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
mode_type = PaymentModeType.objects.create(label="Espèces")
payment_mode = PaymentMode.objects.create(mode=mode_type, establishment=est)
self.assertEqual(payment_mode.mode, mode_type)
self.assertEqual(payment_mode.establishment, est)
class CompetencyModelTest(TestCase):
def test_create_competency(self):
cat = Category.objects.create(name="Maths", domain_id=1)
comp = Competency.objects.create(name="Compétence 1", category=cat)
self.assertEqual(comp.name, "Compétence 1")
self.assertEqual(comp.category, cat)
class EstablishmentCompetencyModelTest(TestCase):
def test_create_establishment_competency(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
cat = Category.objects.create(name="Maths", domain_id=1)
comp = Competency.objects.create(name="Compétence 2", category=cat)
est_comp = EstablishmentCompetency.objects.create(establishment=est, competency=comp)
self.assertEqual(est_comp.establishment, est)
self.assertEqual(est_comp.competency, comp)

View File

@ -37,7 +37,7 @@
<body>
<div class="container">
<div class="header">
<img src="{{URL_DJANGO}}static/img/logo_min.svg" alt="Logo N3wt School" class="logo" />
<img src="{{URL_DJANGO}}/static/img/logo_min.svg" alt="Logo N3wt School" class="logo" />
<h1>Confirmation de souscription</h1>
</div>
<div class="content">

View File

@ -0,0 +1,97 @@
from django.test import TestCase
from .models import Language, Guardian, Sibling, BilanCompetence, Student, RegistrationFileGroup, RegistrationForm, RegistrationSchoolFileMaster, RegistrationParentFileMaster, RegistrationSchoolFileTemplate, StudentCompetency, RegistrationParentFileTemplate, AbsenceManagement
from django.utils import timezone
from datetime import date
from Establishment.models import Establishment
class LanguageModelTest(TestCase):
def test_create_language(self):
lang = Language.objects.create(label="Français")
self.assertEqual(lang.label, "Français")
self.assertIsNotNone(lang.id)
class GuardianModelTest(TestCase):
def test_create_guardian(self):
guardian = Guardian.objects.create(last_name="Dupont", first_name="Jean")
self.assertEqual(guardian.last_name, "Dupont")
self.assertEqual(guardian.first_name, "Jean")
class SiblingModelTest(TestCase):
def test_create_sibling(self):
sibling = Sibling.objects.create(last_name="Martin", first_name="Julie")
self.assertEqual(sibling.last_name, "Martin")
self.assertEqual(sibling.first_name, "Julie")
class BilanCompetenceModelTest(TestCase):
def test_create_bilan(self):
student = Student.objects.create(last_name="Test", first_name="Eleve")
bilan = BilanCompetence.objects.create(student=student, period="T1-2024_2025")
self.assertEqual(bilan.student, student)
self.assertEqual(bilan.period, "T1-2024_2025")
class StudentModelTest(TestCase):
def test_create_student(self):
student = Student.objects.create(last_name="Durand", first_name="Paul")
self.assertEqual(student.last_name, "Durand")
self.assertEqual(student.first_name, "Paul")
class RegistrationFileGroupModelTest(TestCase):
def test_create_group(self):
group = RegistrationFileGroup.objects.create(name="Groupe A")
self.assertEqual(group.name, "Groupe A")
class RegistrationFormModelTest(TestCase):
def test_create_registration_form(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
student = Student.objects.create(last_name="Test", first_name="Eleve")
group = RegistrationFileGroup.objects.create(name="Groupe B", establishment=est)
form = RegistrationForm.objects.create(student=student, fileGroup=group, establishment=est)
self.assertEqual(form.student, student)
self.assertEqual(form.fileGroup, group)
self.assertEqual(form.establishment, est)
class RegistrationSchoolFileMasterModelTest(TestCase):
def test_create_school_file_master(self):
master = RegistrationSchoolFileMaster.objects.create(id=1, name="Doc école")
self.assertEqual(master.name, "Doc école")
class RegistrationParentFileMasterModelTest(TestCase):
def test_create_parent_file_master(self):
master = RegistrationParentFileMaster.objects.create(name="Doc parent")
self.assertEqual(master.name, "Doc parent")
class RegistrationSchoolFileTemplateModelTest(TestCase):
def test_create_school_file_template(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
master = RegistrationSchoolFileMaster.objects.create(id=2, name="Doc école 2")
student = Student.objects.create(last_name="Test", first_name="Eleve")
group = RegistrationFileGroup.objects.create(name="Groupe C", establishment=est)
form = RegistrationForm.objects.create(student=student, fileGroup=group, establishment=est)
template = RegistrationSchoolFileTemplate.objects.create(id=2, master=master, name="Fichier école", registration_form=form)
self.assertEqual(template.name, "Fichier école")
self.assertEqual(template.master, master)
class StudentCompetencyModelTest(TestCase):
def test_create_student_competency(self):
student = Student.objects.create(last_name="Test", first_name="Eleve")
# Pour le test, on suppose qu'un modèle School.EstablishmentCompetency existe et est importable
# Ici, on ne peut pas créer l'objet sans ce modèle, donc ce test est à adapter selon la base réelle
pass
class RegistrationParentFileTemplateModelTest(TestCase):
def test_create_parent_file_template(self):
est = Establishment.objects.create(name="École Test", address="1 rue", total_capacity=10, establishment_type=[1], evaluation_frequency=1, licence_code="A")
master = RegistrationParentFileMaster.objects.create(name="Doc parent 2")
student = Student.objects.create(last_name="Test", first_name="Eleve")
group = RegistrationFileGroup.objects.create(name="Groupe D", establishment=est)
form = RegistrationForm.objects.create(student=student, fileGroup=group, establishment=est)
template = RegistrationParentFileTemplate.objects.create(master=master, registration_form=form)
self.assertEqual(template.master, master)
self.assertEqual(template.registration_form, form)
class AbsenceManagementModelTest(TestCase):
def test_create_absence(self):
student = Student.objects.create(last_name="Test", first_name="Eleve")
absence = AbsenceManagement.objects.create(student=student, day=date.today())
self.assertEqual(absence.student, student)
self.assertEqual(absence.day, date.today())

View File

@ -1 +1 @@
__version__ = "0.0.2"
__version__ = "0.0.3"

3
Back-End/pytest.ini Normal file
View File

@ -0,0 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE = N3wtSchool.settings
python_files = tests.py test_*.py *_tests.py

View File

@ -70,3 +70,6 @@ xhtml2pdf==0.2.16
channels==4.0.0
channels-redis==4.1.0
daphne==4.1.0
pytest
pytest-django
pytest-json-report

View File

@ -2,6 +2,13 @@
Toutes les modifications notables apportées à ce projet seront documentées dans ce fichier.
### [0.0.3](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/compare/0.0.2...0.0.3) (2025-06-01)
### Corrections de bugs
* Ajout d'un '/' en fin d'URL ([67cea2f](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/commit/67cea2f1c6edae8eed5e024c79b1e19d08788d4c))
### 0.0.2 (2025-06-01)
@ -161,7 +168,7 @@ Toutes les modifications notables apportées à ce projet seront documentées da
* ajout de credential include dans get CSRF ([c161fa7](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/commit/c161fa7e7568437ba501a565ad53192b9cb3b6f3))
* Ajout de l'établissement dans la requête KPI récupérant les ([ada2a44](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/commit/ada2a44c3ec9ba45462bd7e78984dfa38008e231))
* Ajout des niveaux scolaires dans le back [[#27](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/issues/27)] ([05542df](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/commit/05542dfc40649fd194ee551f0298f1535753f219))
* ajout des urls prod et demo ([b780e8b](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/commit/b780e8b4ff4b5e6bbbccf1c77a56136c0c4affcb)), closes [#1](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/issues/1) [#123](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/issues/123)
* ajout des urls prod et demo ([043d93d](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/commit/043d93dcc476e5eb3962fdbe0f6a81b937122647))
* Ajout du % ou € en mode édition de réduction ([f2628bb](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/commit/f2628bb45a14da42d014e42b1521820ffeedfb33))
* Ajout du controle sur le format des dates ([e538ac3](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/commit/e538ac3d56294d4e647a38d730168ea567c76f04))
* Ajout du mode Visu ([e1c6073](https://git.v0id.ovh:5022/n3wt-innov/n3wt-school/commit/e1c607308c12cf75695e9d4593dc27ebe74e6a4f))

View File

@ -1,6 +1,6 @@
{
"name": "n3wt-school-front-end",
"version": "0.0.2",
"version": "0.0.3",
"private": true,
"scripts": {
"dev": "next dev",

22
conf/backend.env.default Normal file
View File

@ -0,0 +1,22 @@
TZ="Europe/Paris"
TEST_MODE=true
CSRF_COOKIE_SECURE=true
CSRF_COOKIE_DOMAIN=".localhost"
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000,http://localhost:8080,http://127.0.0.1:8080
CSRF_TRUSTED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000,http://localhost:8080,http://127.0.0.1:8080
BASE_URL=http://localhost:3000
DEBUG=false
EMAIL_HOST="smtp.hostinger.com"
EMAIL_PORT="587"
EMAIL_HOST_USER=""
EMAIL_HOST_PASSWORD=''
EMAIL_USE_TLS=true
EMAIL_USE_SSL=false
DB_NAME="school"
DB_USER="postgres"
DB_PASSWORD="postgres"
DB_HOST="database"
DB_PORT="5432"
URL_DJANGO="http://localhost:8080"
SECRET_KEY="<SIGNINGKEY>"

View File

@ -1,15 +1,19 @@
services:
redis:
image: 'redis:latest'
image: "redis:latest"
volumes:
- redis-data:/data
expose:
- 6379
environment:
- TZ=Europe/Paris
database:
image: 'postgres:latest'
image: "postgres:latest"
expose:
- 5432
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
@ -20,17 +24,13 @@ services:
image: git.v0id.ovh/n3wt-innov/n3wt-school/backend:latest
ports:
- 8080:8080
environment:
- TZ=Europe/Paris
- TEST_MODE=True
env_file: "./conf/backend.env"
links:
- "database:database"
- "redis:redis"
depends_on:
- redis
- database
volumes:
- ./conf/application.json:/Back-End/Subscriptions/Configuration/application.json
command: python start.py
frontend:
@ -40,6 +40,8 @@ services:
environment:
- TZ=Europe/Paris
- NODE_ENV=production
- NEXT_PUBLIC_API_URL=http://toto:8080
depends_on:
- backend
volumes:
- ./conf/env:/app/.env
volumes:
postgres-data:
redis-data:

View File

@ -1,55 +1,24 @@
services:
redis:
image: "redis:latest"
ports:
- 6379:6379
volumes:
- redis-data:/data
expose:
- 6379
environment:
- TZ=Europe/Paris
database:
image: "postgres:latest"
ports:
- 5432:5432
expose:
- 5432
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: school
TZ: Europe/Paris
# docuseal_db:
# image: postgres:latest
# environment:
# POSTGRES_USER: postgres
# POSTGRES_PASSWORD: postgres
# DOCUSEAL_DB_HOST: docuseal_db
# POSTGRES_DB: docuseal
# ports:
# - 5433:5432 # port différent si besoin d'accès direct depuis l'hôte
# docuseal:
# image: docuseal/docuseal:latest
# container_name: docuseal_app
# depends_on:
# - docuseal_db
# ports:
# - "3001:3000"
# environment:
# DATABASE_URL: postgresql://postgres:postgres@docuseal_db:5432/docuseal
# volumes:
# - ./docuseal:/data/docuseal
# caddy:
# image: caddy:2
# container_name: caddy
# restart: unless-stopped
# ports:
# - "4000:4443"
# volumes:
# - ./Caddyfile:/etc/caddy/Caddyfile
# - caddy_data:/data
# - caddy_config:/config
# depends_on:
# - docuseal
backend:
build:
@ -58,54 +27,29 @@ services:
- 8080:8080
volumes:
- ./Back-End:/Back-End
environment:
- TZ=Europe/Paris
- TEST_MODE=True
- CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000,http://localhost:8080,http://127.0.0.1:8080
- CSRF_TRUSTED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000,http://localhost:8080,http://127.0.0.1:8080
- BASE_URL=http://localhost:3000
env_file: "./conf/backend.env"
links:
- "database:database"
- "redis:redis"
depends_on:
- redis
- database
#- docuseal
command: python start.py
# init_docuseal_users:
# build:
# context: .
# dockerfile: Dockerfile
# depends_on:
# - docuseal
# environment:
# DOCUSEAL_DB_HOST: docuseal_db
# POSTGRES_USER: postgres
# POSTGRES_PASSWORD: postgres
# USER_FIRST_NAME: n3wt
# USER_LAST_NAME: school
# USER_COMPANY: n3wt.innov
# USER_EMAIL: n3wt.school@gmail.com
# USER_PASSWORD: n3wt1234
# volumes:
# - ./initDocusealUsers.sh:/docker-entrypoint-initdb.d/initDocusealUsers.sh
backend-test:
build:
context: ./Back-End
volumes:
- ./Back-End:/Back-End
env_file: "./conf/backend.env"
links:
- "database:database"
- "redis:redis"
depends_on:
- redis
- database
command: python manage.py test
# frontend:
# build:
# context: ./Front-End
# args:
# - BUILD_MODE=development
# ports:
# - 3000:3000
# volumes:
# - ./Front-End:/app
# env_file:
# - .env
# environment:
# - TZ=Europe/Paris
# depends_on:
# - backend
volumes:
caddy_data:
caddy_config:
postgres-data:
redis-data:

View File

@ -1,6 +1,6 @@
{
"name": "n3wt-school",
"version": "0.0.2",
"version": "0.0.3",
"scripts": {
"prepare": "husky",
"release": "standard-version",