From 085c086ec7278dc2073540140385f203d09aed61 Mon Sep 17 00:00:00 2001 From: N3WT DE COMPET Date: Sat, 1 Mar 2025 15:41:12 +0100 Subject: [PATCH] =?UTF-8?q?chore:=20Cr=C3=A9ation=20d'un=20mock=20data=20d?= =?UTF-8?q?e=2050=20RF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/commands/init_mock_datas.py | 46 +++++++++--------- Back-End/requirements.txt | Bin 2490 -> 2554 bytes .../Structure/Files/FilesGroupsManagement.js | 1 - 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Back-End/School/management/commands/init_mock_datas.py b/Back-End/School/management/commands/init_mock_datas.py index 2f74379..4ae7ed3 100644 --- a/Back-End/School/management/commands/init_mock_datas.py +++ b/Back-End/School/management/commands/init_mock_datas.py @@ -6,8 +6,7 @@ from Subscriptions.models import ( Guardian, Fee, Discount, - RegistrationFileGroup, - # RegistrationFileTemplate + RegistrationFileGroup ) from Auth.models import Profile from School.models import ( @@ -29,6 +28,7 @@ from django.core.files import File from django.core.exceptions import SuspiciousFileOperation import os from django.conf import settings +from faker import Faker class Command(BaseCommand): help = 'Initialise toutes les données mock' @@ -448,26 +448,21 @@ class Command(BaseCommand): self.stdout.write(self.style.SUCCESS('RegistrationFileTemplates initialized or updated successfully')) + from faker import Faker + def create_register_form(self): - # Créer ou mettre à jour le profil associé au guardian - profiles_data = [ - { - "email": "anthony.casini.30@gmail.com", + fake = Faker('fr_FR') # Utiliser le locale français pour Faker + + for _ in range(50): + # Générer des données fictives pour le profil + profile_data = { + "email": fake.email(), "droit": 2, - "username": "anthony.casini.30@gmail.com", - "is_active": True, - "password": "Provisoire01!" - }, - { - "email": "anthony.audrey.34@gmail.com", - "droit": 2, - "username": "anthony.audrey.34@gmail.com", + "username": fake.user_name(), "is_active": True, "password": "Provisoire01!" } - ] - for profile_data in profiles_data: user, created = Profile.objects.update_or_create( email=profile_data["email"], defaults={ @@ -481,16 +476,23 @@ class Command(BaseCommand): user.set_password(profile_data["password"]) user.save() - # Créer les données du guardian + # Générer des données fictives pour le guardian guardian_data = { "associated_profile_id": user.id, "email": profile_data["email"], } - # Créer les données de l'étudiant + # Générer des données fictives pour l'étudiant student_data = { - "last_name": f'lastname_{user.id}', - "first_name": f'firstname_{user.id}', + "last_name": fake.last_name(), + "first_name": fake.first_name(), + "address": fake.address(), + "birth_date": fake.date_of_birth(), + "birth_place": fake.city(), + "birth_postal_code": fake.postcode(), + "nationality": fake.country(), + "attending_physician": fake.name(), + "level": fake.random_int(min=1, max=6) } # Créer ou mettre à jour l'étudiant et le guardian @@ -514,7 +516,7 @@ class Command(BaseCommand): "student": student, "fileGroup": self.registration_file_group_1, "establishment": Establishment.objects.get(id=1), - "status": 1 + "status": fake.random_int(min=1, max=3) } # Créer ou mettre à jour le formulaire d'inscription @@ -525,4 +527,4 @@ class Command(BaseCommand): register_form.fileGroup = self.registration_file_group_1 register_form.save() - self.stdout.write(self.style.SUCCESS('RegistrationForm initialized or updated successfully')) \ No newline at end of file + self.stdout.write(self.style.SUCCESS('50 RegistrationForms initialized or updated successfully')) \ No newline at end of file diff --git a/Back-End/requirements.txt b/Back-End/requirements.txt index 11ec216ce424226521876445e69c486c7470a461..85047c7134981a7ff888d613229aab754e2d1d64 100644 GIT binary patch delta 70 zcmdlb{7ZO46pM5|Lo!1tLoq`tLn1>CgDnsmGUzcF0I~7pU=~eDH=uYnP__sxXUt#* OlmV$Q++5D$%nAS>-wlQU delta 16 Xcmew*yi0gP6wBlq7NyO5SnOB { setGroups(groupsData); setTemplates(filesTemplates); - console.log("coucou : ", filesTemplates) // Sélectionner automatiquement le premier groupe s'il existe if (groupsData.length > 0) { setSelectedGroup(groupsData[0].id.toString());