mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
feat: Création nouveau style / pagination profils annuaires
This commit is contained in:
@ -31,7 +31,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', blank=True)
|
||||
profile_role = models.OneToOneField(ProfileRole, on_delete=models.CASCADE, related_name='guardian_profile', null=True, blank=True)
|
||||
|
||||
@property
|
||||
def email(self):
|
||||
|
||||
@ -2,10 +2,10 @@ from rest_framework.pagination import PageNumberPagination
|
||||
|
||||
from N3wtSchool import settings
|
||||
|
||||
class CustomPagination(PageNumberPagination):
|
||||
class CustomSubscriptionPagination(PageNumberPagination):
|
||||
page_size_query_param = 'page_size'
|
||||
max_page_size = settings.NB_MAX_PAGE
|
||||
page_size = settings.NB_RESULT_PER_PAGE
|
||||
page_size = settings.NB_RESULT_SUBSCRIPTIONS_PER_PAGE
|
||||
|
||||
def get_paginated_response(self, data):
|
||||
return ({
|
||||
|
||||
@ -137,9 +137,19 @@ class StudentSerializer(serializers.ModelSerializer):
|
||||
def create_or_update_guardians(self, guardians_data):
|
||||
guardians_ids = []
|
||||
for guardian_data in guardians_data:
|
||||
guardian_id = guardian_data.get('id', None)
|
||||
profile_role_data = guardian_data.pop('profile_role_data', None)
|
||||
profile_role = guardian_data.pop('profile_role', None)
|
||||
|
||||
if guardian_id:
|
||||
# Si un ID est fourni, récupérer ou mettre à jour le Guardian existant
|
||||
guardian_instance, created = Guardian.objects.update_or_create(
|
||||
id=guardian_id,
|
||||
defaults=guardian_data
|
||||
)
|
||||
guardians_ids.append(guardian_instance.id)
|
||||
continue
|
||||
|
||||
if profile_role_data:
|
||||
# Vérifiez si 'profile_data' est fourni pour créer un nouveau profil
|
||||
profile_data = profile_role_data.pop('profile_data', None)
|
||||
@ -410,4 +420,4 @@ class NotificationSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Notification
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ import Subscriptions.mailManager as mailer
|
||||
import Subscriptions.util as util
|
||||
|
||||
from Subscriptions.serializers import RegistrationFormSerializer, RegistrationSchoolFileTemplateSerializer, RegistrationParentFileTemplateSerializer
|
||||
from Subscriptions.pagination import CustomPagination
|
||||
from Subscriptions.pagination import CustomSubscriptionPagination
|
||||
from Subscriptions.models import Student, Guardian, RegistrationForm, RegistrationSchoolFileTemplate, RegistrationFileGroup, RegistrationParentFileTemplate
|
||||
from Subscriptions.automate import updateStateMachine
|
||||
|
||||
@ -29,7 +29,7 @@ class RegisterFormView(APIView):
|
||||
"""
|
||||
Gère la liste des dossiers d’inscription, lecture et création.
|
||||
"""
|
||||
pagination_class = CustomPagination
|
||||
pagination_class = CustomSubscriptionPagination
|
||||
|
||||
@swagger_auto_schema(
|
||||
manual_parameters=[
|
||||
@ -82,7 +82,7 @@ class RegisterFormView(APIView):
|
||||
try:
|
||||
page_size = int(page_size)
|
||||
except ValueError:
|
||||
page_size = settings.NB_RESULT_PER_PAGE
|
||||
page_size = settings.NB_RESULT_SUBSCRIPTIONS_PER_PAGE
|
||||
|
||||
# Récupérer les années scolaires
|
||||
current_year = util.getCurrentSchoolYear()
|
||||
@ -179,7 +179,7 @@ class RegisterFormWithIdView(APIView):
|
||||
"""
|
||||
Gère la lecture, création, modification et suppression d’un dossier d’inscription.
|
||||
"""
|
||||
pagination_class = CustomPagination
|
||||
pagination_class = CustomSubscriptionPagination
|
||||
|
||||
@swagger_auto_schema(
|
||||
responses={200: RegistrationFormSerializer()},
|
||||
|
||||
Reference in New Issue
Block a user