MarisiaS / SMM

0 stars 0 forks source link

BE- Athlete model, serializer and view #54

Closed viriponce closed 6 months ago

viriponce commented 6 months ago

This PR addresses issue #21

Implementation

  1. backend/api/models.py Implemented the Athlete model with the following fields:
  1. backend/api/migrations/0011_athlete.py After creating the model, I ran the makemigrations command and the migration for the Athlete model was created.

  2. backend/api/serializers/AthleteSerializer.py Created a Model serializer for the Athlete model. Included all the fields. Add a validation method for date_of_birth to check the date is not in the future.

  3. backend/api/views/AthleteView.py Created a basic Model View set for Athlete.

  4. backend/api/urls.py Added a router to generate the endpoints for Athlete.

  5. backend/api/fixtures/setup_data.json

Added data for 6 Athlete objects.

I applied the migration with migrate command, then loaded the fixture data with loaddata command.

Swagger

The endpoints are accessible through Swagger:

Screenshot 2024-02-22 at 10 26 57 AM

I tried each of the new endpoints successfully. I was able to create, delete, patch and get an athlete. When posting and patching, I got the expected error for entering invalid data.