MarisiaS / SMM

0 stars 0 forks source link

BE-Register Schools to Swim Meet #60

Closed MarisiaS closed 6 months ago

MarisiaS commented 6 months ago

This PR addresses issue #29

Implementation

  1. backend/api/models.py

Added a Many-to-Many field to the SwimMeet model to establish a link between a swim meet and a list of schools.

  1. backend/api/migrations/0011_swimmeet.py

Deleted existing migration and generated a new one by running the makemigrations command.

  1. backend/api/serializers/MeetSchoolSerializer.py
  1. backend/api/views/MeetSchoolView.py

Created an APIView named MeetSchoolView with:

  1. backend/api/urls.py

Added the following endpoint:

Database

The following table was added because we added the ManytoMany field linking SwimMeet with School:

image

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.

MarisiaS commented 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: image