feat: Formulaire de création RF sur une seule pag

This commit is contained in:
N3WT DE COMPET
2025-05-05 20:57:51 +02:00
parent 2a6b3bdf63
commit 76f9a7dd14
19 changed files with 1299 additions and 422 deletions

View File

@ -33,7 +33,7 @@ class RegisterFormView(APIView):
@swagger_auto_schema(
manual_parameters=[
openapi.Parameter('filter', openapi.IN_QUERY, description="filtre", type=openapi.TYPE_STRING, enum=['pending', 'archived', 'subscribed'], required=True),
openapi.Parameter('filter', openapi.IN_QUERY, description="filtre", type=openapi.TYPE_STRING, enum=['current_year', 'next_year', 'historical'], required=True),
openapi.Parameter('search', openapi.IN_QUERY, description="search", type=openapi.TYPE_STRING, required=False),
openapi.Parameter('page_size', openapi.IN_QUERY, description="limite de page lors de la pagination", type=openapi.TYPE_INTEGER, required=False),
openapi.Parameter('establishment_id', openapi.IN_QUERY, description="ID de l'établissement", type=openapi.TYPE_INTEGER, required=True),
@ -51,7 +51,7 @@ class RegisterFormView(APIView):
"last_name": "Doe",
"date_of_birth": "2010-01-01"
},
"status": "pending",
"status": "current_year",
"last_update": "10-02-2025 10:00"
},
{
@ -62,7 +62,7 @@ class RegisterFormView(APIView):
"last_name": "Doe",
"date_of_birth": "2011-02-02"
},
"status": "archived",
"status": "historical",
"last_update": "09-02-2025 09:00"
}
]
@ -85,14 +85,19 @@ class RegisterFormView(APIView):
except ValueError:
page_size = settings.NB_RESULT_PER_PAGE
# Récupérer les dossier d'inscriptions en fonction du filtre
# Récupérer les années scolaires
current_year = util.getCurrentSchoolYear()
next_year = util.getNextSchoolYear()
historical_years = util.getHistoricalYears()
# Récupérer les dossiers d'inscriptions en fonction du filtre
registerForms_List = None
if filter == 'pending':
exclude_states = [RegistrationForm.RegistrationFormStatus.RF_VALIDATED, RegistrationForm.RegistrationFormStatus.RF_ARCHIVED]
registerForms_List = bdd.searchObjects(RegistrationForm, search, _excludeStates=exclude_states)
elif filter == 'archived':
registerForms_List = bdd.getObjects(RegistrationForm, 'status', RegistrationForm.RegistrationFormStatus.RF_ARCHIVED)
elif filter == 'subscribed':
if filter == 'current_year':
registerForms_List = RegistrationForm.objects.filter(school_year=current_year)
elif filter == 'next_year':
registerForms_List = RegistrationForm.objects.filter(school_year=next_year)
elif filter == 'historical':
registerForms_List = RegistrationForm.objects.filter(school_year__in=historical_years)
registerForms_List = bdd.getObjects(RegistrationForm, 'status', RegistrationForm.RegistrationFormStatus.RF_VALIDATED)
else:
registerForms_List = None
@ -126,7 +131,7 @@ class RegisterFormView(APIView):
"last_name": "Doe",
"date_of_birth": "2010-01-01"
},
"status": "pending",
"status": "current_year",
"last_update": "10-02-2025 10:00",
"codeLienInscription": "ABC123XYZ456"
}
@ -514,4 +519,5 @@ def get_parent_file_templates_by_rf(request, id):
# Retourner les données sérialisées
return JsonResponse(serializer.data, safe=False)
except RegistrationParentFileTemplate.DoesNotExist:
return JsonResponse({'error': 'Aucune pièce à fournir trouvée pour ce dossier d\'inscription'}, status=status.HTTP_404_NOT_FOUND)
return JsonResponse({'error': 'Aucune pièce à fournir trouvée pour ce dossier d\'inscription'}, status=status.HTTP_404_NOT_FOUND)