Closed MarisiaS closed 6 months ago
When deleting schools from a meet through
/api/meet_schools/{meet_id}/
, it's allowing to leve the list without elements and returning a successful message, not sure if we need to add a validation for this case. At the end, no element is deleted which it's ok. What do you think?
I added allow_empty = False for the listField. The new message for empty lists is this one:
This PR addresses issue #29
Implementation
Added a Many-to-Many field to the
SwimMeet
model to establish a link between a swim meet and a list of schools.Deleted existing migration and generated a new one by running the
makemigrations
command.BasicSchoolSerializer
based onModelSerializer
to display only the id and name of each school.MeetSchoolListSerializer
based onModelSerializer
to display the id and name of a swim meet along with the list of schools related to the given swim meet.SchoolsListSerializer
based onSerializer
to display a list of IDs. This serializer validates the existence of a school for each ID in the list.Created an APIView named MeetSchoolView with:
get
method to list the schools associated with a given swim meet. This view uses theMeetSchoolListSerializer
.post
method to associate a list of schools to a given swim meet. Uses theSchoolListSerializer
.patch
method to disassociate a list of schools to a given swim meet. Also uses theSchoolListSerializer
.Added the following endpoint:
/meet_schools/<int:meet_id>/
usesMeetSchoolView
.Database
The following table was added because we added the ManytoMany field linking SwimMeet with School:
Swagger
All new endpoints are accessible through Swagger. Each endpoint has been tested successfully, including listing all schools associated with a swim meet, adding schools to a swim meet, and deleting schools from a swim meet.