mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Signatures électroniques docuseal [#22]
This commit is contained in:
@ -7,7 +7,7 @@ from Subscriptions.models import (
|
||||
Fee,
|
||||
Discount,
|
||||
RegistrationFileGroup,
|
||||
RegistrationFileTemplate
|
||||
# RegistrationFileTemplate
|
||||
)
|
||||
from Auth.models import Profile
|
||||
from School.models import (
|
||||
@ -43,7 +43,7 @@ class Command(BaseCommand):
|
||||
self.create_or_update_teachers()
|
||||
self.create_or_update_school_classes()
|
||||
self.create_or_update_registration_file_group()
|
||||
self.create_or_update_registration_file_template()
|
||||
# self.create_or_update_registration_file_template()
|
||||
self.create_register_form()
|
||||
|
||||
def create_or_update_establishment(self):
|
||||
@ -376,13 +376,21 @@ class Command(BaseCommand):
|
||||
self.stdout.write(self.style.SUCCESS('SchoolClasses initialized or updated successfully'))
|
||||
|
||||
def create_or_update_registration_file_group(self):
|
||||
group_data = {
|
||||
group_data_1 = {
|
||||
"name": "LMDE",
|
||||
"description": "Fichiers d'inscription de l'école LMDE"
|
||||
}
|
||||
|
||||
self.registration_file_group, created = RegistrationFileGroup.objects.get_or_create(name=group_data["name"], defaults=group_data)
|
||||
self.stdout.write(self.style.SUCCESS('RegistrationFileGroup initialized or updated successfully'))
|
||||
self.registration_file_group_1, created = RegistrationFileGroup.objects.get_or_create(name=group_data_1["name"], defaults=group_data_1)
|
||||
self.stdout.write(self.style.SUCCESS('RegistrationFileGroup 1 initialized or updated successfully'))
|
||||
|
||||
group_data_2 = {
|
||||
"name": "LMDE 2",
|
||||
"description": "Fichiers d'inscription de l'école LMDE 2"
|
||||
}
|
||||
|
||||
self.registration_file_group_2, created = RegistrationFileGroup.objects.get_or_create(name=group_data_2["name"], defaults=group_data_2)
|
||||
self.stdout.write(self.style.SUCCESS('RegistrationFileGroup 2 initialized or updated successfully'))
|
||||
|
||||
def create_or_update_registration_file_template(self):
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
@ -394,28 +402,28 @@ class Command(BaseCommand):
|
||||
"file": "RIB LA MAISON DES ENFANTS.pdf",
|
||||
"order": 0,
|
||||
"is_required": False,
|
||||
"group": self.registration_file_group
|
||||
"group": self.registration_file_group_2 # Associer ce fichier au deuxième groupe
|
||||
},
|
||||
{
|
||||
"name": "Contrat d'engagement 2024 2025",
|
||||
"file": "Contrat d'engagement 2024 2025.pdf",
|
||||
"order": 0,
|
||||
"is_required": True,
|
||||
"group": self.registration_file_group
|
||||
"group": self.registration_file_group_1
|
||||
},
|
||||
{
|
||||
"name": "Bulletin d'adhésion familiale scolaire",
|
||||
"file": "Bulletin d'adhésion familiale scolaire.pdf",
|
||||
"order": 0,
|
||||
"is_required": True,
|
||||
"group": self.registration_file_group
|
||||
"group": self.registration_file_group_1
|
||||
},
|
||||
{
|
||||
"name": "Fiche sanitaire de liaison",
|
||||
"file": "Fiche sanitaire de liaison.pdf",
|
||||
"order": 0,
|
||||
"is_required": True,
|
||||
"group": self.registration_file_group
|
||||
"group": self.registration_file_group_1
|
||||
}
|
||||
]
|
||||
|
||||
@ -442,69 +450,79 @@ class Command(BaseCommand):
|
||||
|
||||
def create_register_form(self):
|
||||
# Créer ou mettre à jour le profil associé au guardian
|
||||
profile_data = {
|
||||
"email": "anthony.casini.30@gmail.com",
|
||||
"droit": 2,
|
||||
"username": "anthony.casini.30@gmail.com",
|
||||
"is_active": True,
|
||||
"password": "Provisoire01!"
|
||||
}
|
||||
|
||||
user, created = Profile.objects.update_or_create(
|
||||
email=profile_data["email"],
|
||||
defaults={
|
||||
"username": profile_data["username"],
|
||||
"email": profile_data["email"],
|
||||
"is_active": profile_data["is_active"],
|
||||
"droit": profile_data["droit"]
|
||||
profiles_data = [
|
||||
{
|
||||
"email": "anthony.casini.30@gmail.com",
|
||||
"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",
|
||||
"is_active": True,
|
||||
"password": "Provisoire01!"
|
||||
}
|
||||
)
|
||||
if created:
|
||||
user.set_password(profile_data["password"])
|
||||
user.save()
|
||||
]
|
||||
|
||||
# Créer les données du guardian
|
||||
guardian_data = {
|
||||
"associated_profile_id": user.id,
|
||||
"email": "anthony.casini.30@gmail.com",
|
||||
}
|
||||
for profile_data in profiles_data:
|
||||
user, created = Profile.objects.update_or_create(
|
||||
email=profile_data["email"],
|
||||
defaults={
|
||||
"username": profile_data["username"],
|
||||
"email": profile_data["email"],
|
||||
"is_active": profile_data["is_active"],
|
||||
"droit": profile_data["droit"]
|
||||
}
|
||||
)
|
||||
if created:
|
||||
user.set_password(profile_data["password"])
|
||||
user.save()
|
||||
|
||||
# Créer les données de l'étudiant
|
||||
student_data = {
|
||||
"last_name": "CASINI",
|
||||
"first_name": "Giulia",
|
||||
}
|
||||
# Créer les données du guardian
|
||||
guardian_data = {
|
||||
"associated_profile_id": user.id,
|
||||
"email": profile_data["email"],
|
||||
}
|
||||
|
||||
# Créer ou mettre à jour l'étudiant et le guardian
|
||||
student, created = Student.objects.get_or_create(
|
||||
last_name=student_data["last_name"],
|
||||
first_name=student_data["first_name"],
|
||||
defaults=student_data
|
||||
)
|
||||
guardian, created = Guardian.objects.get_or_create(
|
||||
last_name=guardian_data["email"],
|
||||
defaults=guardian_data
|
||||
)
|
||||
student.guardians.add(guardian)
|
||||
# Créer les données de l'étudiant
|
||||
student_data = {
|
||||
"last_name": f'lastname_{user.id}',
|
||||
"first_name": f'firstname_{user.id}',
|
||||
}
|
||||
|
||||
# Récupérer les frais et les réductions
|
||||
fees = Fee.objects.filter(id__in=[1, 2, 3, 4])
|
||||
discounts = Discount.objects.filter(id__in=[1])
|
||||
# Créer ou mettre à jour l'étudiant et le guardian
|
||||
student, created = Student.objects.get_or_create(
|
||||
last_name=student_data["last_name"],
|
||||
first_name=student_data["first_name"],
|
||||
defaults=student_data
|
||||
)
|
||||
guardian, created = Guardian.objects.get_or_create(
|
||||
last_name=guardian_data["email"],
|
||||
defaults=guardian_data
|
||||
)
|
||||
student.guardians.add(guardian)
|
||||
|
||||
# Créer les données du formulaire d'inscription
|
||||
register_form_data = {
|
||||
"student": student,
|
||||
"fileGroup": self.registration_file_group,
|
||||
"establishment": Establishment.objects.get(id=1),
|
||||
"status": 1
|
||||
}
|
||||
# Récupérer les frais et les réductions
|
||||
fees = Fee.objects.filter(id__in=[1, 2, 3, 4])
|
||||
discounts = Discount.objects.filter(id__in=[1])
|
||||
|
||||
# Créer ou mettre à jour le formulaire d'inscription
|
||||
register_form, created = RegistrationForm.objects.get_or_create(student=student, defaults=register_form_data)
|
||||
register_form.fees.set(fees)
|
||||
register_form.discounts.set(discounts)
|
||||
if not created:
|
||||
register_form.fileGroup = self.registration_file_group
|
||||
register_form.save()
|
||||
# Créer les données du formulaire d'inscription
|
||||
register_form_data = {
|
||||
"student": student,
|
||||
"fileGroup": self.registration_file_group_1,
|
||||
"establishment": Establishment.objects.get(id=1),
|
||||
"status": 1
|
||||
}
|
||||
|
||||
# Créer ou mettre à jour le formulaire d'inscription
|
||||
register_form, created = RegistrationForm.objects.get_or_create(student=student, defaults=register_form_data)
|
||||
register_form.fees.set(fees)
|
||||
register_form.discounts.set(discounts)
|
||||
if not created:
|
||||
register_form.fileGroup = self.registration_file_group_1
|
||||
register_form.save()
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('RegistrationForm initialized or updated successfully'))
|
||||
Reference in New Issue
Block a user