mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
chore: Création d'un mock data de 50 RF
This commit is contained in:
@ -6,8 +6,7 @@ from Subscriptions.models import (
|
|||||||
Guardian,
|
Guardian,
|
||||||
Fee,
|
Fee,
|
||||||
Discount,
|
Discount,
|
||||||
RegistrationFileGroup,
|
RegistrationFileGroup
|
||||||
# RegistrationFileTemplate
|
|
||||||
)
|
)
|
||||||
from Auth.models import Profile
|
from Auth.models import Profile
|
||||||
from School.models import (
|
from School.models import (
|
||||||
@ -29,6 +28,7 @@ from django.core.files import File
|
|||||||
from django.core.exceptions import SuspiciousFileOperation
|
from django.core.exceptions import SuspiciousFileOperation
|
||||||
import os
|
import os
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from faker import Faker
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'Initialise toutes les données mock'
|
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'))
|
self.stdout.write(self.style.SUCCESS('RegistrationFileTemplates initialized or updated successfully'))
|
||||||
|
|
||||||
|
from faker import Faker
|
||||||
|
|
||||||
def create_register_form(self):
|
def create_register_form(self):
|
||||||
# Créer ou mettre à jour le profil associé au guardian
|
fake = Faker('fr_FR') # Utiliser le locale français pour Faker
|
||||||
profiles_data = [
|
|
||||||
{
|
for _ in range(50):
|
||||||
"email": "anthony.casini.30@gmail.com",
|
# Générer des données fictives pour le profil
|
||||||
|
profile_data = {
|
||||||
|
"email": fake.email(),
|
||||||
"droit": 2,
|
"droit": 2,
|
||||||
"username": "anthony.casini.30@gmail.com",
|
"username": fake.user_name(),
|
||||||
"is_active": True,
|
|
||||||
"password": "Provisoire01!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"email": "anthony.audrey.34@gmail.com",
|
|
||||||
"droit": 2,
|
|
||||||
"username": "anthony.audrey.34@gmail.com",
|
|
||||||
"is_active": True,
|
"is_active": True,
|
||||||
"password": "Provisoire01!"
|
"password": "Provisoire01!"
|
||||||
}
|
}
|
||||||
]
|
|
||||||
|
|
||||||
for profile_data in profiles_data:
|
|
||||||
user, created = Profile.objects.update_or_create(
|
user, created = Profile.objects.update_or_create(
|
||||||
email=profile_data["email"],
|
email=profile_data["email"],
|
||||||
defaults={
|
defaults={
|
||||||
@ -481,16 +476,23 @@ class Command(BaseCommand):
|
|||||||
user.set_password(profile_data["password"])
|
user.set_password(profile_data["password"])
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
# Créer les données du guardian
|
# Générer des données fictives pour le guardian
|
||||||
guardian_data = {
|
guardian_data = {
|
||||||
"associated_profile_id": user.id,
|
"associated_profile_id": user.id,
|
||||||
"email": profile_data["email"],
|
"email": profile_data["email"],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Créer les données de l'étudiant
|
# Générer des données fictives pour l'étudiant
|
||||||
student_data = {
|
student_data = {
|
||||||
"last_name": f'lastname_{user.id}',
|
"last_name": fake.last_name(),
|
||||||
"first_name": f'firstname_{user.id}',
|
"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
|
# Créer ou mettre à jour l'étudiant et le guardian
|
||||||
@ -514,7 +516,7 @@ class Command(BaseCommand):
|
|||||||
"student": student,
|
"student": student,
|
||||||
"fileGroup": self.registration_file_group_1,
|
"fileGroup": self.registration_file_group_1,
|
||||||
"establishment": Establishment.objects.get(id=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
|
# 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.fileGroup = self.registration_file_group_1
|
||||||
register_form.save()
|
register_form.save()
|
||||||
|
|
||||||
self.stdout.write(self.style.SUCCESS('RegistrationForm initialized or updated successfully'))
|
self.stdout.write(self.style.SUCCESS('50 RegistrationForms initialized or updated successfully'))
|
||||||
Binary file not shown.
@ -50,7 +50,6 @@ export default function FilesGroupsManagement({ csrfToken }) {
|
|||||||
]).then(([filesTemplateMasters, groupsData, filesTemplates]) => {
|
]).then(([filesTemplateMasters, groupsData, filesTemplates]) => {
|
||||||
setGroups(groupsData);
|
setGroups(groupsData);
|
||||||
setTemplates(filesTemplates);
|
setTemplates(filesTemplates);
|
||||||
console.log("coucou : ", filesTemplates)
|
|
||||||
// Sélectionner automatiquement le premier groupe s'il existe
|
// Sélectionner automatiquement le premier groupe s'il existe
|
||||||
if (groupsData.length > 0) {
|
if (groupsData.length > 0) {
|
||||||
setSelectedGroup(groupsData[0].id.toString());
|
setSelectedGroup(groupsData[0].id.toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user