From 95c154a4a2d746c4350887bb697af142152ed8d7 Mon Sep 17 00:00:00 2001 From: N3WT DE COMPET Date: Thu, 6 Mar 2025 20:38:09 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20Augmentation=20du=20nombre=20de=20d?= =?UTF-8?q?onn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/commands/init_mock_datas.py | 15 ++++----- .../management/mock_datas/file_groups.json | 22 +++++++++++++ .../management/mock_datas/specialities.json | 16 ++++++++++ .../management/mock_datas/teachers.json | 32 +++++++++++++++++-- 4 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 Back-End/School/management/mock_datas/file_groups.json diff --git a/Back-End/School/management/commands/init_mock_datas.py b/Back-End/School/management/commands/init_mock_datas.py index 8e05014..0d68817 100644 --- a/Back-End/School/management/commands/init_mock_datas.py +++ b/Back-End/School/management/commands/init_mock_datas.py @@ -204,18 +204,17 @@ class Command(BaseCommand): self.stdout.write(self.style.SUCCESS('SchoolClasses initialized or updated successfully')) def create_or_update_registration_file_group(self): - for establishment in self.establishments: - group_data = { - "name": f"Fichiers d'inscription - {establishment.name}", - "description": f"Fichiers d'inscription de l'école {establishment.name}" - } + file_groups_data = self.load_data('file_groups.json') + for group_data in file_groups_data: RegistrationFileGroup.objects.update_or_create(name=group_data["name"], defaults=group_data) - self.stdout.write(self.style.SUCCESS(f'RegistrationFileGroup for {establishment.name} initialized or updated successfully')) + self.stdout.write(self.style.SUCCESS(f'RegistrationFileGroup {group_data["name"]} initialized or updated successfully')) def create_register_form(self): fake = Faker('fr_FR') # Utiliser le locale français pour Faker + file_group_count = RegistrationFileGroup.objects.count() + for _ in range(50): establishment = random.choice(self.establishments) @@ -281,7 +280,7 @@ class Command(BaseCommand): # Créer les données du formulaire d'inscription register_form_data = { "student": student, - "fileGroup": RegistrationFileGroup.objects.get(name=f"Fichiers d'inscription - {establishment.name}"), + "fileGroup": RegistrationFileGroup.objects.get(id=fake.random_int(min=1, max=file_group_count)), "establishment": establishment, "status": fake.random_int(min=1, max=3) } @@ -291,7 +290,7 @@ class Command(BaseCommand): register_form.fees.set(fees) register_form.discounts.set(discounts) if not created: - register_form.fileGroup = RegistrationFileGroup.objects.get(name=f"Fichiers d'inscription - {establishment.name}") + register_form.fileGroup = file_group register_form.save() self.stdout.write(self.style.SUCCESS('50 RegistrationForms initialized or updated successfully')) \ No newline at end of file diff --git a/Back-End/School/management/mock_datas/file_groups.json b/Back-End/School/management/mock_datas/file_groups.json new file mode 100644 index 0000000..a188153 --- /dev/null +++ b/Back-End/School/management/mock_datas/file_groups.json @@ -0,0 +1,22 @@ +[ + { + "name": "Fichiers d'inscription - Classe 1 - Ecole A", + "description": "Fichiers d'inscription pour la Classe 1 de l'école Ecole A" + }, + { + "name": "Fichiers d'inscription - Classe 2 - Ecole B", + "description": "Fichiers d'inscription pour la Classe 2 de l'école Ecole B" + }, + { + "name": "Fichiers d'inscription - Classe 3 - Ecole C", + "description": "Fichiers d'inscription pour la Classe 3 de l'école Ecole C" + }, + { + "name": "Fichiers d'inscription - Classe 4 - Ecole A", + "description": "Fichiers d'inscription pour la Classe 4 de l'école Ecole A" + }, + { + "name": "Fichiers d'inscription - Classe 5 - Ecole B", + "description": "Fichiers d'inscription pour la Classe 5 de l'école Ecole B" + } +] \ No newline at end of file diff --git a/Back-End/School/management/mock_datas/specialities.json b/Back-End/School/management/mock_datas/specialities.json index 75707d9..1806e7c 100644 --- a/Back-End/School/management/mock_datas/specialities.json +++ b/Back-End/School/management/mock_datas/specialities.json @@ -22,5 +22,21 @@ { "name": "SPORT", "color_code": "#bbb9b9" + }, + { + "name": "SCIENCES", + "color_code": "#00FF00" + }, + { + "name": "MUSIQUE", + "color_code": "#0000FF" + }, + { + "name": "ART", + "color_code": "#FF00FF" + }, + { + "name": "INFORMATIQUE", + "color_code": "#00FFFF" } ] \ No newline at end of file diff --git a/Back-End/School/management/mock_datas/teachers.json b/Back-End/School/management/mock_datas/teachers.json index 2318577..18ceadc 100644 --- a/Back-End/School/management/mock_datas/teachers.json +++ b/Back-End/School/management/mock_datas/teachers.json @@ -11,14 +11,14 @@ "first_name": "Severus", "email": "severus.rogue@gmail.com", "specialities": ["ANGLAIS"], - "droit": 1 + "droit": 2 }, { "last_name": "MC GONAGALL", "first_name": "Minerva", "email": "minerva.mcgonagall@gmail.com", "specialities": ["MATHS", "HISTOIRE"], - "droit": 1 + "droit": 2 }, { "last_name": "CHOURAVE", @@ -26,5 +26,33 @@ "email": "pomona.chourave@gmail.com", "specialities": ["MATHS", "FRANCAIS", "SPORT"], "droit": 1 + }, + { + "last_name": "HAGRID", + "first_name": "Rubeus", + "email": "rubeus.hagrid@gmail.com", + "specialities": ["SCIENCES"], + "droit": 2 + }, + { + "last_name": "FLITWICK", + "first_name": "Filius", + "email": "filius.flitwick@gmail.com", + "specialities": ["MUSIQUE"], + "droit": 1 + }, + { + "last_name": "SPROUT", + "first_name": "Pomona", + "email": "pomona.sprout@gmail.com", + "specialities": ["ART"], + "droit": 2 + }, + { + "last_name": "SINISTRA", + "first_name": "Aurora", + "email": "aurora.sinistra@gmail.com", + "specialities": ["INFORMATIQUE"], + "droit": 2 } ] \ No newline at end of file