diff --git a/Back-End/School/management/commands/References/CapSchool/Autorisations Parentales 2024-2025.pdf b/Back-End/School/management/commands/References/CapSchool/Autorisations Parentales 2024-2025.pdf new file mode 100644 index 0000000..5c940c7 Binary files /dev/null and b/Back-End/School/management/commands/References/CapSchool/Autorisations Parentales 2024-2025.pdf differ diff --git a/Back-End/School/management/commands/References/CapSchool/Dossier Inscription 24-25.pdf b/Back-End/School/management/commands/References/CapSchool/Dossier Inscription 24-25.pdf new file mode 100644 index 0000000..abdc77e Binary files /dev/null and b/Back-End/School/management/commands/References/CapSchool/Dossier Inscription 24-25.pdf differ diff --git a/Back-End/School/management/commands/References/CapSchool/Règlement Cap School 24-25.pdf b/Back-End/School/management/commands/References/CapSchool/Règlement Cap School 24-25.pdf new file mode 100644 index 0000000..8cab532 Binary files /dev/null and b/Back-End/School/management/commands/References/CapSchool/Règlement Cap School 24-25.pdf differ diff --git a/Back-End/School/management/commands/References/LMDE/Bulletin d'adhésion familiale scolaire.pdf b/Back-End/School/management/commands/References/LMDE/Bulletin d'adhésion familiale scolaire.pdf new file mode 100644 index 0000000..a3b0caa Binary files /dev/null and b/Back-End/School/management/commands/References/LMDE/Bulletin d'adhésion familiale scolaire.pdf differ diff --git a/Back-End/School/management/commands/References/LMDE/Contrat d'engagement 2024 2025.pdf b/Back-End/School/management/commands/References/LMDE/Contrat d'engagement 2024 2025.pdf new file mode 100644 index 0000000..a967e18 Binary files /dev/null and b/Back-End/School/management/commands/References/LMDE/Contrat d'engagement 2024 2025.pdf differ diff --git a/Back-End/School/management/commands/References/LMDE/Fiche d'inscription 2024 2025.pdf b/Back-End/School/management/commands/References/LMDE/Fiche d'inscription 2024 2025.pdf new file mode 100644 index 0000000..54c2ed0 Binary files /dev/null and b/Back-End/School/management/commands/References/LMDE/Fiche d'inscription 2024 2025.pdf differ diff --git a/Back-End/School/management/commands/References/LMDE/Fiche sanitaire de liaison.pdf b/Back-End/School/management/commands/References/LMDE/Fiche sanitaire de liaison.pdf new file mode 100644 index 0000000..d4de1d7 Binary files /dev/null and b/Back-End/School/management/commands/References/LMDE/Fiche sanitaire de liaison.pdf differ diff --git a/Back-End/School/management/commands/References/LMDE/RIB LA MAISON DES ENFANTS.pdf b/Back-End/School/management/commands/References/LMDE/RIB LA MAISON DES ENFANTS.pdf new file mode 100644 index 0000000..528c95b Binary files /dev/null and b/Back-End/School/management/commands/References/LMDE/RIB LA MAISON DES ENFANTS.pdf differ diff --git a/Back-End/School/management/commands/init_establishment.py b/Back-End/School/management/commands/init_establishment.py deleted file mode 100644 index 874ee15..0000000 --- a/Back-End/School/management/commands/init_establishment.py +++ /dev/null @@ -1,24 +0,0 @@ -from django.core.management.base import BaseCommand -from School.models import Establishment, StructureType - -class Command(BaseCommand): - help = 'Initialize the establishment' - - def handle(self, *args, **kwargs): - establishment_data = { - "name": "N3WT", - "address": "Société n3wt-innov 69 Chez LANA", - "total_capacity": 69, - "establishment_type": [StructureType.MATERNELLE, StructureType.PRIMAIRE], - "licence_code": "" - } - - establishment, created = Establishment.objects.update_or_create( - name=establishment_data["name"], - defaults=establishment_data - ) - - if created: - self.stdout.write(self.style.SUCCESS('Establishment created successfully')) - else: - self.stdout.write(self.style.SUCCESS('Establishment updated successfully')) \ No newline at end of file diff --git a/Back-End/School/management/commands/init_mock_datas.py b/Back-End/School/management/commands/init_mock_datas.py new file mode 100644 index 0000000..8fd8ac4 --- /dev/null +++ b/Back-End/School/management/commands/init_mock_datas.py @@ -0,0 +1,510 @@ +from django.core.management.base import BaseCommand +from django.contrib.auth.models import User +from Subscriptions.models import ( + RegistrationForm, + Student, + Guardian, + Fee, + Discount, + RegistrationFileGroup, + RegistrationFileTemplate +) +from Auth.models import Profile +from School.models import ( + Establishment, + FeeType, + Speciality, + Teacher, + SchoolClass, + PaymentMode, + PaymentModeType, + PaymentPlan, + PaymentPlanType, + StructureType, + DiscountType +) +from django.utils import timezone +from dateutil.relativedelta import relativedelta +from django.core.files import File +from django.core.exceptions import SuspiciousFileOperation +import os +from django.conf import settings + +class Command(BaseCommand): + help = 'Initialise toutes les données mock' + + def handle(self, *args, **kwargs): + self.create_or_update_establishment() + self.create_or_update_fees() + self.create_or_update_discounts() + self.create_or_update_payment_modes() + self.create_or_update_payment_plans() + self.create_or_update_specialities() + 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_register_form() + + def create_or_update_establishment(self): + establishment_data = { + "name": "N3WT", + "address": "Société n3wt-innov 69 Chez LANA", + "total_capacity": 69, + "establishment_type": [StructureType.MATERNELLE, StructureType.PRIMAIRE], + "licence_code": "" + } + + establishment, created = Establishment.objects.update_or_create( + name=establishment_data["name"], + defaults=establishment_data + ) + + if created: + self.stdout.write(self.style.SUCCESS('Establishment created successfully')) + else: + self.stdout.write(self.style.SUCCESS('Establishment updated successfully')) + + def create_or_update_fees(self): + establishment = Establishment.objects.get(name="N3WT") + fees_data = [ + { + "name": "Frais d'inscription", + "base_amount": "150.00", + "description": "Montant de base", + "is_active": True, + "type": FeeType.REGISTRATION_FEE, + "establishment": establishment + }, + { + "name": "Matériel", + "base_amount": "85.00", + "description": "Livres / jouets", + "is_active": True, + "type": FeeType.REGISTRATION_FEE, + "establishment": establishment + }, + { + "name": "Sorties périscolaires", + "base_amount": "120.00", + "description": "Sorties", + "is_active": True, + "type": FeeType.REGISTRATION_FEE, + "establishment": establishment + }, + { + "name": "Les colibris", + "base_amount": "4500.00", + "description": "TPS / PS / MS / GS", + "is_active": True, + "type": FeeType.TUITION_FEE, + "establishment": establishment + }, + { + "name": "Les butterflies", + "base_amount": "5000.00", + "description": "CP / CE1 / CE2 / CM1 / CM2", + "is_active": True, + "type": FeeType.TUITION_FEE, + "establishment": establishment + } + ] + + for fee_data in fees_data: + Fee.objects.update_or_create( + name=fee_data["name"], + type=fee_data["type"], + defaults=fee_data + ) + + self.stdout.write(self.style.SUCCESS('Fees initialized or updated successfully')) + + def create_or_update_discounts(self): + establishment = Establishment.objects.get(name="N3WT") + discounts_data = [ + { + "name": "Parrainage", + "amount": "10.00", + "description": "Réduction pour parrainage", + "discount_type": DiscountType.PERCENT, + "type": FeeType.TUITION_FEE, + "establishment": establishment + }, + { + "name": "Réinscription", + "amount": "100.00", + "description": "Réduction pour Réinscription", + "discount_type": DiscountType.PERCENT, + "type": FeeType.REGISTRATION_FEE, + "establishment": establishment + } + ] + + for discount_data in discounts_data: + Discount.objects.update_or_create( + name=discount_data["name"], + type=discount_data["type"], + discount_type=discount_data["discount_type"], + defaults=discount_data + ) + + self.stdout.write(self.style.SUCCESS('Discounts initialized or updated successfully')) + + def create_or_update_payment_modes(self): + establishment = Establishment.objects.get(name="N3WT") + for fee_type in FeeType.choices: + fee_type_value = fee_type[0] + + for mode in PaymentModeType.choices: + mode_value = mode[0] + + PaymentMode.objects.update_or_create( + mode=mode_value, + type=fee_type_value, + defaults={ + 'is_active': False, + 'establishment': establishment + } + ) + + self.stdout.write(self.style.SUCCESS('Payment Modes initialized or updated successfully')) + + def create_or_update_payment_plans(self): + current_date = timezone.now().date() + establishment = Establishment.objects.get(name="N3WT") + + for fee_type in FeeType.choices: + fee_type_value = fee_type[0] + + # 1 fois - échéance à 1 mois à partir de la date actuelle + PaymentPlan.objects.update_or_create( + frequency=PaymentPlanType.ONE_TIME, + type=fee_type_value, + defaults={ + 'due_dates': [current_date + relativedelta(months=1)], + 'is_active': True, + 'establishment': establishment + } + ) + + # 3 fois - échéances espacées de 4 mois + PaymentPlan.objects.update_or_create( + frequency=PaymentPlanType.THREE_TIMES, + type=fee_type_value, + defaults={ + 'due_dates': [current_date + relativedelta(months=1+4*i) for i in range(3)], + 'is_active': False, + 'establishment': establishment + } + ) + + # 10 fois - échéances espacées d'un mois + PaymentPlan.objects.update_or_create( + frequency=PaymentPlanType.TEN_TIMES, + type=fee_type_value, + defaults={ + 'due_dates': [current_date + relativedelta(months=1+i) for i in range(10)], + 'is_active': False, + 'establishment': establishment + } + ) + + # 12 fois - échéances espacées d'un mois + PaymentPlan.objects.update_or_create( + frequency=PaymentPlanType.TWELVE_TIMES, + type=fee_type_value, + defaults={ + 'due_dates': [current_date + relativedelta(months=1+i) for i in range(12)], + 'is_active': False, + 'establishment': establishment + } + ) + + self.stdout.write(self.style.SUCCESS('Payment Plans initialized or updated successfully')) + + def create_or_update_specialities(self): + specialities_data = [ + { + "name": "GROUPE", + "color_code": "#FF0000" + }, + { + "name": "MATHS", + "color_code": "#0a98f0" + }, + { + "name": "ANGLAIS", + "color_code": "#f708d7" + }, + { + "name": "FRANCAIS", + "color_code": "#04f108" + }, + { + "name": "HISTOIRE", + "color_code": "#ffb005" + }, + { + "name": "SPORT", + "color_code": "#bbb9b9" + } + ] + + for speciality_data in specialities_data: + Speciality.objects.update_or_create( + name=speciality_data["name"], + defaults=speciality_data + ) + self.stdout.write(self.style.SUCCESS('Specialities initialized or updated successfully')) + + def create_or_update_teachers(self): + teachers_data = [ + { + "last_name": "DUMBLEDORE", + "first_name": "Albus", + "email": "albus.dumbledore@gmail.com", + "specialities": ["GROUPE"], + "droit": 1 + }, + { + "last_name": "ROGUE", + "first_name": "Severus", + "email": "severus.rogue@gmail.com", + "specialities": ["ANGLAIS"], + "droit": 0 + }, + { + "last_name": "MC GONAGALL", + "first_name": "Minerva", + "email": "minerva.mcgonagall@gmail.com", + "specialities": ["MATHS", "HISTOIRE"], + "droit": 0 + }, + { + "last_name": "CHOURAVE", + "first_name": "Pomona", + "email": "pomona.chourave@gmail.com", + "specialities": ["MATHS", "FRANCAIS", "SPORT"], + "droit": 0 + } + ] + + for teacher_data in teachers_data: + specialities = teacher_data.pop("specialities") + email = teacher_data["email"] + droit = teacher_data.pop("droit") + + # Create or update the user profile + user, created = Profile.objects.update_or_create( + email=email, + defaults={ + "username": email, + "email": email, + "is_active": True, + "password": "Provisoire01!", + "droit": droit + } + ) + if created: + user.set_password("Provisoire01!") + user.save() + + # Create or update the teacher + teacher, created = Teacher.objects.update_or_create( + email=email, + defaults={**teacher_data, "associated_profile_id": user.id} + ) + teacher.specialities.set(Speciality.objects.filter(name__in=specialities)) + teacher.save() + + self.stdout.write(self.style.SUCCESS('Teachers initialized or updated successfully')) + + def create_or_update_school_classes(self): + establishment = Establishment.objects.get(name="N3WT") + school_classes_data = [ + { + "atmosphere_name": "Classe A", + "age_range": "3-6", + "number_of_students": 14, + "teaching_language": "", + "school_year": "2024-2025", + "levels": [2, 3, 4], + "type": 1, + "time_range": ["08:30", "17:30"], + "opening_days": [1, 2, 4, 5], + "teachers": [2], # ID of Severus Rogue + "establishment": establishment + }, + { + "atmosphere_name": "Classe B", + "age_range": "2-3", + "number_of_students": 5, + "teaching_language": "", + "school_year": "2024-2025", + "levels": [1], + "type": 1, + "time_range": ["08:30", "17:30"], + "opening_days": [1, 2, 4, 5], + "teachers": [3], # ID of Minerva McGonagall + "establishment": establishment + }, + { + "atmosphere_name": "Classe C", + "age_range": "6-12", + "number_of_students": 21, + "teaching_language": "", + "school_year": "2024-2025", + "levels": [5, 6, 7, 8, 9], + "type": 1, + "time_range": ["08:30", "17:30"], + "opening_days": [1, 2, 4, 5], + "teachers": [4], # ID of Pomona Chourave + "establishment": establishment + } + ] + + for class_data in school_classes_data: + teachers_ids = class_data.pop("teachers") + school_class, created = SchoolClass.objects.update_or_create( + atmosphere_name=class_data["atmosphere_name"], + school_year=class_data["school_year"], + defaults=class_data + ) + school_class.teachers.set(teachers_ids) + school_class.save() + + self.stdout.write(self.style.SUCCESS('SchoolClasses initialized or updated successfully')) + + def create_or_update_registration_file_group(self): + group_data = { + "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')) + + def create_or_update_registration_file_template(self): + script_dir = os.path.dirname(os.path.abspath(__file__)) + references_dir = os.path.join(script_dir, 'References', 'LMDE') + + templates_data = [ + { + "name": "RIB LA MAISON DES ENFANTS", + "file": "RIB LA MAISON DES ENFANTS.pdf", + "order": 0, + "is_required": False, + "group": self.registration_file_group + }, + { + "name": "Contrat d'engagement 2024 2025", + "file": "Contrat d'engagement 2024 2025.pdf", + "order": 0, + "is_required": True, + "group": self.registration_file_group + }, + { + "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 + }, + { + "name": "Fiche sanitaire de liaison", + "file": "Fiche sanitaire de liaison.pdf", + "order": 0, + "is_required": True, + "group": self.registration_file_group + } + ] + + for template_data in templates_data: + file_path = os.path.join(references_dir, template_data["file"]) + references_dir_realpath = os.path.realpath(references_dir) + file_path_realpath = os.path.realpath(file_path) + if not file_path_realpath.startswith(references_dir_realpath): + raise SuspiciousFileOperation(f"Detected path traversal attempt in '{file_path_realpath}'") + if not os.path.exists(file_path_realpath): + raise FileNotFoundError(f"File not found: {file_path_realpath}") + with open(file_path_realpath, 'rb') as file: + RegistrationFileTemplate.objects.update_or_create( + name=template_data["name"], + defaults={ + "file": File(file, name=template_data["file"]), + "order": template_data["order"], + "is_required": template_data["is_required"], + "group": template_data["group"] + } + ) + + self.stdout.write(self.style.SUCCESS('RegistrationFileTemplates initialized or updated successfully')) + + 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"] + } + ) + 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", + } + + # Créer les données de l'étudiant + student_data = { + "last_name": "CASINI", + "first_name": "Giulia", + } + + # 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) + + # 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 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 + } + + # 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() + + self.stdout.write(self.style.SUCCESS('RegistrationForm initialized or updated successfully')) \ No newline at end of file diff --git a/Back-End/School/management/commands/init_payment_modes.py b/Back-End/School/management/commands/init_payment_modes.py deleted file mode 100644 index 844a2f6..0000000 --- a/Back-End/School/management/commands/init_payment_modes.py +++ /dev/null @@ -1,27 +0,0 @@ -from django.core.management.base import BaseCommand -from School.models import PaymentMode, PaymentModeType, FeeType, Establishment - -class Command(BaseCommand): - help = 'Initialize or update Payment Modes' - - def handle(self, *args, **kwargs): - self.create_or_update_payment_modes() - - def create_or_update_payment_modes(self): - establishment = Establishment.objects.get(name="N3WT") - for fee_type in FeeType.choices: - fee_type_value = fee_type[0] - - for mode in PaymentModeType.choices: - mode_value = mode[0] - - PaymentMode.objects.update_or_create( - mode=mode_value, - type=fee_type_value, - defaults={ - 'is_active': False, - 'establishment': establishment - } - ) - - self.stdout.write(self.style.SUCCESS('Payment Modes initialized or updated successfully')) \ No newline at end of file diff --git a/Back-End/School/management/commands/init_payment_plans.py b/Back-End/School/management/commands/init_payment_plans.py deleted file mode 100644 index 919e902..0000000 --- a/Back-End/School/management/commands/init_payment_plans.py +++ /dev/null @@ -1,63 +0,0 @@ -from django.core.management.base import BaseCommand -from django.utils import timezone -from dateutil.relativedelta import relativedelta -from School.models import PaymentPlan, PaymentPlanType, FeeType, Establishment - -class Command(BaseCommand): - help = 'Initialize or update Payment Plans' - - def handle(self, *args, **kwargs): - self.create_or_update_payment_plans() - - def create_or_update_payment_plans(self): - current_date = timezone.now().date() - establishment = Establishment.objects.get(name="N3WT") - - for fee_type in FeeType.choices: - fee_type_value = fee_type[0] - - # 1 fois - échéance à 1 mois à partir de la date actuelle - PaymentPlan.objects.update_or_create( - frequency=PaymentPlanType.ONE_TIME, - type=fee_type_value, - defaults={ - 'due_dates': [current_date + relativedelta(months=1)], - 'is_active': True, - 'establishment': establishment - } - ) - - # 3 fois - échéances espacées de 4 mois - PaymentPlan.objects.update_or_create( - frequency=PaymentPlanType.THREE_TIMES, - type=fee_type_value, - defaults={ - 'due_dates': [current_date + relativedelta(months=1+4*i) for i in range(3)], - 'is_active': False, - 'establishment': establishment - } - ) - - # 10 fois - échéances espacées d'un mois - PaymentPlan.objects.update_or_create( - frequency=PaymentPlanType.TEN_TIMES, - type=fee_type_value, - defaults={ - 'due_dates': [current_date + relativedelta(months=1+i) for i in range(10)], - 'is_active': False, - 'establishment': establishment - } - ) - - # 12 fois - échéances espacées d'un mois - PaymentPlan.objects.update_or_create( - frequency=PaymentPlanType.TWELVE_TIMES, - type=fee_type_value, - defaults={ - 'due_dates': [current_date + relativedelta(months=1+i) for i in range(12)], - 'is_active': False, - 'establishment': establishment - } - ) - - self.stdout.write(self.style.SUCCESS('Payment Plans initialized or updated successfully')) \ No newline at end of file diff --git a/Back-End/School/management/commands/init_school_configuration.py b/Back-End/School/management/commands/init_school_configuration.py deleted file mode 100644 index 4a5a298..0000000 --- a/Back-End/School/management/commands/init_school_configuration.py +++ /dev/null @@ -1,164 +0,0 @@ -from django.core.management.base import BaseCommand -from Auth.models import Profile -from School.models import Speciality, Teacher, SchoolClass, Establishment - -class Command(BaseCommand): - help = 'Initialize or update Fees and Discounts' - - def handle(self, *args, **kwargs): - self.create_or_update_specialities() - self.create_or_update_teachers() - self.create_or_update_schoolClasses() - - def create_or_update_specialities(self): - specialities_data = [ - { - "name": "GROUPE", - "color_code": "#FF0000" - }, - { - "name": "MATHS", - "color_code": "#0a98f0" - }, - { - "name": "ANGLAIS", - "color_code": "#f708d7" - }, - { - "name": "FRANCAIS", - "color_code": "#04f108" - }, - { - "name": "HISTOIRE", - "color_code": "#ffb005" - }, - { - "name": "SPORT", - "color_code": "#bbb9b9" - } - ] - - for speciality_data in specialities_data: - Speciality.objects.update_or_create( - name=speciality_data["name"], - defaults=speciality_data - ) - self.stdout.write(self.style.SUCCESS('Specialities initialized or updated successfully')) - - def create_or_update_teachers(self): - teachers_data = [ - { - "last_name": "DUMBLEDORE", - "first_name": "Albus", - "email": "albus.dumbledore@gmail.com", - "specialities": ["GROUPE"], - "droit": 1 - }, - { - "last_name": "ROGUE", - "first_name": "Severus", - "email": "severus.rogue@gmail.com", - "specialities": ["ANGLAIS"], - "droit": 0 - }, - { - "last_name": "MC GONAGALL", - "first_name": "Minerva", - "email": "minerva.mcgonagall@gmail.com", - "specialities": ["MATHS", "HISTOIRE"], - "droit": 0 - }, - { - "last_name": "CHOURAVE", - "first_name": "Pomona", - "email": "pomona.chourave@gmail.com", - "specialities": ["MATHS", "FRANCAIS", "SPORT"], - "droit": 0 - } - ] - - for teacher_data in teachers_data: - specialities = teacher_data.pop("specialities") - email = teacher_data["email"] - droit = teacher_data.pop("droit") - - # Create or update the user profile - user, created = Profile.objects.update_or_create( - email=email, - defaults={ - "username": email, - "email": email, - "is_active": True, - "password": "Provisoire01!", - "droit": droit - } - ) - if created: - user.set_password("Provisoire01!") - user.save() - - # Create or update the teacher - teacher, created = Teacher.objects.update_or_create( - email=email, - defaults={**teacher_data, "associated_profile_id": user.id} - ) - teacher.specialities.set(Speciality.objects.filter(name__in=specialities)) - teacher.save() - - self.stdout.write(self.style.SUCCESS('Teachers initialized or updated successfully')) - - def create_or_update_schoolClasses(self): - establishment = Establishment.objects.get(name="N3WT") - school_classes_data = [ - { - "atmosphere_name": "Classe A", - "age_range": "3-6", - "number_of_students": 14, - "teaching_language": "", - "school_year": "2024-2025", - "levels": [2, 3, 4], - "type": 1, - "time_range": ["08:30", "17:30"], - "opening_days": [1, 2, 4, 5], - "teachers": [2], # ID of Severus Rogue - "establishment": establishment - }, - { - "atmosphere_name": "Classe B", - "age_range": "2-3", - "number_of_students": 5, - "teaching_language": "", - "school_year": "2024-2025", - "levels": [1], - "type": 1, - "time_range": ["08:30", "17:30"], - "opening_days": [1, 2, 4, 5], - "teachers": [3], # ID of Minerva McGonagall - "establishment": establishment - }, - { - "atmosphere_name": "Classe C", - "age_range": "6-12", - "number_of_students": 21, - "teaching_language": "", - "school_year": "2024-2025", - "levels": [5, 6, 7, 8, 9], - "type": 1, - "time_range": ["08:30", "17:30"], - "opening_days": [1, 2, 4, 5], - "teachers": [4], # ID of Pomona Chourave - "establishment": establishment - } - ] - - for class_data in school_classes_data: - teachers_ids = class_data.pop("teachers") - school_class, created = SchoolClass.objects.update_or_create( - atmosphere_name=class_data["atmosphere_name"], - school_year=class_data["school_year"], - defaults=class_data - ) - school_class.teachers.set(teachers_ids) - school_class.save() - - self.stdout.write(self.style.SUCCESS('SchoolClasses initialized or updated successfully')) \ No newline at end of file diff --git a/Back-End/School/management/commands/init_school_fees.py b/Back-End/School/management/commands/init_school_fees.py deleted file mode 100644 index c26c79b..0000000 --- a/Back-End/School/management/commands/init_school_fees.py +++ /dev/null @@ -1,96 +0,0 @@ -from django.core.management.base import BaseCommand -from Auth.models import Profile -from School.models import Fee, Discount, FeeType, DiscountType, Establishment - -class Command(BaseCommand): - help = 'Initialize or update Fees and Discounts' - - def handle(self, *args, **kwargs): - self.create_or_update_fees() - self.create_or_update_discounts() - - def create_or_update_fees(self): - establishment = Establishment.objects.get(name="N3WT") - fees_data = [ - { - "name": "Frais d'inscription", - "base_amount": "150.00", - "description": "Montant de base", - "is_active": True, - "type": FeeType.REGISTRATION_FEE, - "establishment": establishment - }, - { - "name": "Matériel", - "base_amount": "85.00", - "description": "Livres / jouets", - "is_active": True, - "type": FeeType.REGISTRATION_FEE, - "establishment": establishment - }, - { - "name": "Sorties périscolaires", - "base_amount": "120.00", - "description": "Sorties", - "is_active": True, - "type": FeeType.REGISTRATION_FEE, - "establishment": establishment - }, - { - "name": "Les colibris", - "base_amount": "4500.00", - "description": "TPS / PS / MS / GS", - "is_active": True, - "type": FeeType.TUITION_FEE, - "establishment": establishment - }, - { - "name": "Les butterflies", - "base_amount": "5000.00", - "description": "CP / CE1 / CE2 / CM1 / CM2", - "is_active": True, - "type": FeeType.TUITION_FEE, - "establishment": establishment - } - ] - - for fee_data in fees_data: - Fee.objects.update_or_create( - name=fee_data["name"], - type=fee_data["type"], - defaults=fee_data - ) - - self.stdout.write(self.style.SUCCESS('Fees initialized or updated successfully')) - - def create_or_update_discounts(self): - establishment = Establishment.objects.get(name="N3WT") - discounts_data = [ - { - "name": "Parrainage", - "amount": "10.00", - "description": "Réduction pour parrainage", - "discount_type": DiscountType.PERCENT, - "type": FeeType.TUITION_FEE, - "establishment": establishment - }, - { - "name": "Réinscription", - "amount": "100.00", - "description": "Réduction pour Réinscription", - "discount_type": DiscountType.PERCENT, - "type": FeeType.REGISTRATION_FEE, - "establishment": establishment - } - ] - - for discount_data in discounts_data: - Discount.objects.update_or_create( - name=discount_data["name"], - type=discount_data["type"], - discount_type=discount_data["discount_type"], - defaults=discount_data - ) - - self.stdout.write(self.style.SUCCESS('Discounts initialized or updated successfully')) - \ No newline at end of file diff --git a/Back-End/Subscriptions/serializers.py b/Back-End/Subscriptions/serializers.py index 461caa0..eb147e7 100644 --- a/Back-End/Subscriptions/serializers.py +++ b/Back-End/Subscriptions/serializers.py @@ -186,8 +186,6 @@ class RegistrationFormSerializer(serializers.ModelSerializer): return local_time.strftime("%d-%m-%Y %H:%M") def get_totalRegistrationFees(self, obj): - for fee in obj.fees.filter(type=FeeType.REGISTRATION_FEE): - print(fee.base_amount) return sum(fee.base_amount for fee in obj.fees.filter(type=FeeType.REGISTRATION_FEE)) def get_totalTuitionFees(self, obj): diff --git a/Back-End/start.py b/Back-End/start.py index 28d60f4..ca1d961 100644 --- a/Back-End/start.py +++ b/Back-End/start.py @@ -24,11 +24,7 @@ commands = [ ] test_commands = [ - ["python", "manage.py", "init_establishment"], - ["python", "manage.py", "init_school_configuration"], - ["python", "manage.py", "init_school_fees"], - ["python", "manage.py", "init_payment_plans"], - ["python", "manage.py", "init_payment_modes"] + ["python", "manage.py", "init_mock_datas"] ] for command in commands: