mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +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,
|
||||
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'))
|
||||
self.stdout.write(self.style.SUCCESS('50 RegistrationForms initialized or updated successfully'))
|
||||
Binary file not shown.
Reference in New Issue
Block a user