mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
fix: Correction dépendances circulaires
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
@ -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}"
|
||||
# def __str__(self):
|
||||
# return f"{self.student} - {self.competency.name} - Score: {self.score}"
|
||||
Reference in New Issue
Block a user