mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
refactor: Augmentation du nombre de données
This commit is contained in:
@ -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'))
|
||||
Reference in New Issue
Block a user