From fc9a1ed252e1e115e4a2f7c4a3a04ee6757be683 Mon Sep 17 00:00:00 2001 From: N3WT DE COMPET Date: Mon, 12 May 2025 15:16:46 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Correction=20d=C3=A9pendances=20circulai?= =?UTF-8?q?res?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back-End/Auth/models.py | 3 +- Back-End/Common/__init__.py | 0 Back-End/Common/admin.py | 3 ++ Back-End/Common/apps.py | 6 +++ Back-End/Common/models.py | 13 ++++++ Back-End/Common/tests.py | 3 ++ Back-End/Common/views.py | 3 ++ Back-End/GestionMessagerie/views.py | 7 +-- .../management/commands/init_mock_datas.py | 19 ++------ Back-End/School/models.py | 46 +++++++++---------- Back-End/Subscriptions/models.py | 27 +++++------ 11 files changed, 70 insertions(+), 60 deletions(-) create mode 100644 Back-End/Common/__init__.py create mode 100644 Back-End/Common/admin.py create mode 100644 Back-End/Common/apps.py create mode 100644 Back-End/Common/models.py create mode 100644 Back-End/Common/tests.py create mode 100644 Back-End/Common/views.py diff --git a/Back-End/Auth/models.py b/Back-End/Auth/models.py index c3ac742..95b36ea 100644 --- a/Back-End/Auth/models.py +++ b/Back-End/Auth/models.py @@ -2,7 +2,6 @@ from django.contrib.auth.models import AbstractUser from django.db import models from django.utils.translation import gettext_lazy as _ from django.core.validators import EmailValidator -from Establishment.models import Establishment class Profile(AbstractUser): email = models.EmailField(max_length=255, unique=True, default="", validators=[EmailValidator()]) @@ -25,7 +24,7 @@ class ProfileRole(models.Model): profile = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='roles') role_type = models.IntegerField(choices=RoleType.choices, default=RoleType.PROFIL_UNDEFINED) - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='profile_roles') + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='profile_roles') is_active = models.BooleanField(default=False) updated_date = models.DateTimeField(auto_now=True) diff --git a/Back-End/Common/__init__.py b/Back-End/Common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Back-End/Common/admin.py b/Back-End/Common/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/Back-End/Common/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Back-End/Common/apps.py b/Back-End/Common/apps.py new file mode 100644 index 0000000..1345f2c --- /dev/null +++ b/Back-End/Common/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class CommonConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'Common' diff --git a/Back-End/Common/models.py b/Back-End/Common/models.py new file mode 100644 index 0000000..055cae6 --- /dev/null +++ b/Back-End/Common/models.py @@ -0,0 +1,13 @@ +from django.db import models + +class StudentCompetency(models.Model): + student = models.ForeignKey('Subscriptions.Student', on_delete=models.CASCADE, related_name='competency_scores') + competency = models.ForeignKey('School.Competency', on_delete=models.CASCADE, related_name='student_scores') + score = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True) + comment = models.TextField(blank=True, null=True) + + class Meta: + unique_together = ('student', 'competency') + + def __str__(self): + return f"{self.student} - {self.competency.name} - Score: {self.score}" diff --git a/Back-End/Common/tests.py b/Back-End/Common/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/Back-End/Common/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Back-End/Common/views.py b/Back-End/Common/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/Back-End/Common/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/Back-End/GestionMessagerie/views.py b/Back-End/GestionMessagerie/views.py index ad8fdc9..61db0a4 100644 --- a/Back-End/GestionMessagerie/views.py +++ b/Back-End/GestionMessagerie/views.py @@ -1,17 +1,14 @@ from django.http.response import JsonResponse from rest_framework.views import APIView from rest_framework.parsers import JSONParser -from django.core.mail import send_mail -from django.utils.html import strip_tags from django.conf import settings from rest_framework.response import Response from rest_framework import status from django.db.models import Q -from Auth.models import Profile # Assurez-vous que le modèle Profile contient les informations nécessaires +from Auth.models import Profile, ProfileRole from .models import * -from School.models import Teacher, ProfileRole -from Settings.models import SMTPSettings # Assurez-vous que le chemin est correct +from School.models import Teacher from GestionMessagerie.serializers import MessageSerializer from School.serializers import TeacherSerializer diff --git a/Back-End/School/management/commands/init_mock_datas.py b/Back-End/School/management/commands/init_mock_datas.py index 48d026a..003da40 100644 --- a/Back-End/School/management/commands/init_mock_datas.py +++ b/Back-End/School/management/commands/init_mock_datas.py @@ -1,30 +1,21 @@ from django.core.management.base import BaseCommand from Subscriptions.models import ( RegistrationForm, - Student, - Guardian, - Fee, - Discount, - RegistrationFileGroup, - RegistrationSchoolFileMaster, - RegistrationSchoolFileTemplate + RegistrationFileGroup ) from Auth.models import Profile, ProfileRole from School.models import ( FeeType, Speciality, Teacher, - SchoolClass, - PaymentMode, PaymentModeType, - PaymentPlan, PaymentPlanType, - DiscountType + DiscountType, + Fee, + Discount, ) 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 from faker import Faker @@ -42,7 +33,7 @@ from School.serializers import ( ) from Auth.serializers import ProfileSerializer, ProfileRoleSerializer from Establishment.serializers import EstablishmentSerializer -from Subscriptions.serializers import RegistrationFormSerializer, StudentSerializer +from Subscriptions.serializers import StudentSerializer from Subscriptions.util import getCurrentSchoolYear, getNextSchoolYear # Import des fonctions nécessaires diff --git a/Back-End/School/models.py b/Back-End/School/models.py index 059620e..b5a48f6 100644 --- a/Back-End/School/models.py +++ b/Back-End/School/models.py @@ -1,6 +1,4 @@ from django.db import models -from Auth.models import ProfileRole -from Establishment.models import Establishment from django.db.models import JSONField from django.dispatch import receiver from django.contrib.postgres.fields import ArrayField @@ -23,7 +21,7 @@ class Speciality(models.Model): name = models.CharField(max_length=100) updated_date = models.DateTimeField(auto_now=True) color_code = models.CharField(max_length=7, default='#FFFFFF') - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='specialities') + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='specialities') def __str__(self): return self.name @@ -32,7 +30,7 @@ class Teacher(models.Model): last_name = models.CharField(max_length=100) first_name = models.CharField(max_length=100) specialities = models.ManyToManyField(Speciality, blank=True) - profile_role = models.OneToOneField(ProfileRole, on_delete=models.CASCADE, related_name='teacher_profile', null=True, blank=True) + profile_role = models.OneToOneField('Auth.ProfileRole', on_delete=models.CASCADE, related_name='teacher_profile', null=True, blank=True) updated_date = models.DateTimeField(auto_now=True) def __str__(self): @@ -56,7 +54,7 @@ class SchoolClass(models.Model): type = models.IntegerField(choices=PLANNING_TYPE_CHOICES, default=1) time_range = models.JSONField(default=list) opening_days = ArrayField(models.IntegerField(), default=list) - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='school_classes') + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='school_classes') def __str__(self): return self.atmosphere_name @@ -96,7 +94,7 @@ class Discount(models.Model): discount_type = models.IntegerField(choices=DiscountType.choices, default=DiscountType.CURRENCY) type = models.IntegerField(choices=FeeType.choices, default=FeeType.REGISTRATION_FEE) updated_at = models.DateTimeField(auto_now=True) - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='discounts') + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='discounts') def __str__(self): return self.name @@ -108,7 +106,7 @@ class Fee(models.Model): is_active = models.BooleanField(default=True) updated_at = models.DateTimeField(auto_now=True) type = models.IntegerField(choices=FeeType.choices, default=FeeType.REGISTRATION_FEE) - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='fees') + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='fees') def __str__(self): return self.name @@ -118,7 +116,7 @@ class PaymentPlan(models.Model): due_dates = ArrayField(models.DateField(), blank=True) type = models.IntegerField(choices=FeeType.choices, default=FeeType.REGISTRATION_FEE) is_active = models.BooleanField(default=False) - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='payment_plans') + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='payment_plans') def __str__(self): return f"{self.get_frequency_display()} - {self.get_type_display()}" @@ -127,7 +125,7 @@ class PaymentMode(models.Model): mode = models.IntegerField(choices=PaymentModeType.choices, default=PaymentModeType.SEPA) type = models.IntegerField(choices=FeeType.choices, default=FeeType.REGISTRATION_FEE) is_active = models.BooleanField(default=False) - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='payment_modes') + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='payment_modes') def __str__(self): return f"{self.get_mode_display()} - {self.get_type_display()}" @@ -155,7 +153,7 @@ class Competency(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='competencies') establishments = models.ManyToManyField( - Establishment, + 'Establishment.Establishment', through='EstablishmentCompetency', related_name='competencies', blank=True @@ -169,7 +167,7 @@ class EstablishmentCompetency(models.Model): Relation entre un établissement et une compétence. Permet de définir quelles compétences sont sélectionnées par un établissement. """ - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE) + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE) competency = models.ForeignKey(Competency, on_delete=models.CASCADE) is_selected = models.BooleanField(default=False) @@ -180,18 +178,18 @@ class EstablishmentCompetency(models.Model): return f"{self.establishment.name} - {self.competency.name}" -class StudentCompetency(models.Model): - """ - Relation entre un élève et une compétence. - Permet d'attribuer une note à un élève pour une compétence. - """ - student = models.ForeignKey('Subscriptions.Student', on_delete=models.CASCADE, related_name='competency_scores') - competency = models.ForeignKey(Competency, on_delete=models.CASCADE, related_name='student_scores') - score = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True) # Note attribuée - comment = models.TextField(blank=True, null=True) # Commentaire facultatif +# class StudentCompetency(models.Model): +# """ +# Relation entre un élève et une compétence. +# Permet d'attribuer une note à un élève pour une compétence. +# """ +# student = models.ForeignKey('Subscriptions.Student', on_delete=models.CASCADE, related_name='competency_scores') +# competency = models.ForeignKey(Competency, on_delete=models.CASCADE, related_name='student_scores') +# score = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True) # Note attribuée +# comment = models.TextField(blank=True, null=True) # Commentaire facultatif - class Meta: - unique_together = ('student', 'competency') +# class Meta: +# unique_together = ('student', 'competency') - def __str__(self): - return f"{self.student} - {self.competency.name} - Score: {self.score}" \ No newline at end of file +# def __str__(self): +# return f"{self.student} - {self.competency.name} - Score: {self.score}" \ No newline at end of file diff --git a/Back-End/Subscriptions/models.py b/Back-End/Subscriptions/models.py index 7e44db4..0e3c1a6 100644 --- a/Back-End/Subscriptions/models.py +++ b/Back-End/Subscriptions/models.py @@ -3,11 +3,8 @@ from django.utils.timezone import now from django.conf import settings from django.utils.translation import gettext_lazy as _ -from School.models import SchoolClass, Fee, Discount, PaymentModeType, PaymentPlanType -from Auth.models import ProfileRole -from Establishment.models import Establishment - from datetime import datetime +from School.models import PaymentModeType, PaymentPlanType import os @@ -31,7 +28,7 @@ class Guardian(models.Model): address = models.CharField(max_length=200, default="", blank=True) phone = models.CharField(max_length=200, default="", blank=True) profession = models.CharField(max_length=200, default="", blank=True) - profile_role = models.OneToOneField(ProfileRole, on_delete=models.CASCADE, related_name='guardian_profile', null=True, blank=True) + profile_role = models.OneToOneField('Auth.ProfileRole', on_delete=models.CASCADE, related_name='guardian_profile', null=True, blank=True) @property def email(self): @@ -100,19 +97,19 @@ class Student(models.Model): profiles = models.ManyToManyField('Auth.Profile', blank=True) # Many-to-Many Relationship - guardians = models.ManyToManyField(Guardian, blank=True) + guardians = models.ManyToManyField('Subscriptions.Guardian', blank=True) # Many-to-Many Relationship - siblings = models.ManyToManyField(Sibling, blank=True) + siblings = models.ManyToManyField('Subscriptions.Sibling', blank=True) # Many-to-Many Relationship - registration_files = models.ManyToManyField('RegistrationSchoolFileTemplate', blank=True, related_name='students') + registration_files = models.ManyToManyField('Subscriptions.RegistrationSchoolFileTemplate', blank=True, related_name='students') # Many-to-Many Relationship - spoken_languages = models.ManyToManyField(Language, blank=True) + spoken_languages = models.ManyToManyField('Subscriptions.Language', blank=True) # One-to-Many Relationship - associated_class = models.ForeignKey(SchoolClass, on_delete=models.SET_NULL, null=True, blank=True, related_name='students') + associated_class = models.ForeignKey('School.SchoolClass', on_delete=models.SET_NULL, null=True, blank=True, related_name='students') def __str__(self): return self.last_name + "_" + self.first_name @@ -190,7 +187,7 @@ class Student(models.Model): class RegistrationFileGroup(models.Model): name = models.CharField(max_length=255, default="") description = models.TextField(blank=True, null=True) - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='file_group', null=True, blank=True) + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='file_group', null=True, blank=True) def __str__(self): return self.name @@ -239,17 +236,17 @@ class RegistrationForm(models.Model): associated_rf = models.CharField(max_length=200, default="", blank=True) # Many-to-Many Relationship - fees = models.ManyToManyField(Fee, blank=True, related_name='register_forms') + fees = models.ManyToManyField('School.Fee', blank=True, related_name='register_forms') # Many-to-Many Relationship - discounts = models.ManyToManyField(Discount, blank=True, related_name='register_forms') + discounts = models.ManyToManyField('School.Discount', blank=True, related_name='register_forms') fileGroup = models.ForeignKey(RegistrationFileGroup, on_delete=models.SET_NULL, related_name='register_forms', null=True, blank=True) - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='register_forms') + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='register_forms') registration_payment = models.IntegerField(choices=PaymentModeType.choices, null=True, blank=True) tuition_payment = models.IntegerField(choices=PaymentModeType.choices, null=True, blank=True) registration_payment_plan = models.IntegerField(choices=PaymentPlanType.choices, null=True, blank=True) @@ -386,7 +383,7 @@ class AbsenceManagement(models.Model): on_delete=models.CASCADE, related_name='absences' ) - establishment = models.ForeignKey(Establishment, on_delete=models.CASCADE, related_name='absences') + establishment = models.ForeignKey('Establishment.Establishment', on_delete=models.CASCADE, related_name='absences') def __str__(self): return f"{self.student} - {self.day} - {self.get_moment_display()} - {self.get_reason_display()}" \ No newline at end of file