mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
refactor: Utilisation d'une application "Common" pour tous les modèles
de référence
This commit is contained in:
@ -4,12 +4,15 @@ from Subscriptions.models import (
|
||||
RegistrationFileGroup
|
||||
)
|
||||
from Auth.models import Profile, ProfileRole
|
||||
from Common.models import (
|
||||
PaymentModeType,
|
||||
PaymentPlanType,
|
||||
Level
|
||||
)
|
||||
from School.models import (
|
||||
FeeType,
|
||||
Speciality,
|
||||
Teacher,
|
||||
PaymentModeType,
|
||||
PaymentPlanType,
|
||||
DiscountType,
|
||||
Fee,
|
||||
Discount,
|
||||
@ -280,6 +283,7 @@ class Command(BaseCommand):
|
||||
|
||||
def init_school_classes(self):
|
||||
school_classes_data = self.load_data('school_classes.json')
|
||||
levels = list(Level.objects.all())
|
||||
|
||||
for index, class_data in enumerate(school_classes_data, start=1):
|
||||
# Randomize establishment
|
||||
@ -288,7 +292,7 @@ class Command(BaseCommand):
|
||||
class_data["establishment"] = establishment.id
|
||||
|
||||
# Randomize levels
|
||||
class_data["levels"] = random.sample(range(1, 10), random.randint(1, 5))
|
||||
class_data["levels"] = [level.id for level in random.sample(levels, random.randint(1, min(5, len(levels))))]
|
||||
|
||||
# Randomize teachers
|
||||
establishment_teachers = list(Teacher.objects.filter(profile_role__establishment=establishment))
|
||||
@ -331,6 +335,7 @@ class Command(BaseCommand):
|
||||
fake = Faker('fr_FR') # Utiliser le locale français pour Faker
|
||||
|
||||
file_group_count = RegistrationFileGroup.objects.count()
|
||||
levels = list(Level.objects.all())
|
||||
|
||||
# Récupérer tous les profils existants avec un ProfileRole Parent
|
||||
profiles_with_parent_role = Profile.objects.filter(roles__role_type=ProfileRole.RoleType.PROFIL_PARENT).distinct()
|
||||
@ -376,7 +381,7 @@ class Command(BaseCommand):
|
||||
"birth_postal_code": fake.postcode(),
|
||||
"nationality": fake.country(),
|
||||
"attending_physician": fake.name(),
|
||||
"level": fake.random_int(min=1, max=6),
|
||||
"level": random.choice(levels).id,
|
||||
"guardians": [guardian_data],
|
||||
"sibling": []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user