Implemented the TimeRecord model with the following fields:
athlete = This is a foreignKey to Athlete. Set on_delete to cascade.
event_type = This is a foreignKey to EventType. Set on_delete to cascade.
swim_meet = This is a foreignKey to SwimMeet. Set on_delete to cascade.
time = This is a CharField to represent an athlete's time in minutes:seconds.milliseconds format.
date = This is a DateField to represent the date when the time record was set.
For the Athlete model, the property full_name was added.
backend/api/migrations/0013_timerecord.py
Migration file generated with command makemigrations for TimeRecord model.
backend/api/serializers/TimeRecordSerializer.py
Created TimeRecordSerializer based on ModelSerializer to display almost all the information about an the time record and added the event_type_name and athlete_full_name fields.
In this file, created the validation method validate_time to ensure the format for this field is valid [M:]S.mm.
backend/api/views/TimeRecordView.py
Created a ModelViewSet named TimeRecordViewSet.
Overrode the list method to add the parameters athlete_name and event_type_id in order to use them as filters.
Overrode the get_queryset method to implement the filter logic in case athlete_name or event_type_id were provided.
backend/api/urls.py
Added the following endpoint:
Added a router to generate the endpoints for TimeRecord.
backend/api/fixtures/time_record.json
A fixture file called time_record.json was created with multiple time record objects.
All new endpoints are accessible through Swagger. Each endpoint has been tested successfully, including listing all Time Records which shows all the record information and includes the athlete full name and event type name associated with the record.
For listing, the records can be filtered by athlete_name and event_type_id. When athlete_name parameter is provided, the time records for the athletes whose first name or last name start with the provided value are displayed.
When event_type_id parameter is provided, the time records for the that specific event type are displayed.
This PR addresses issue #25
Implementation
Implemented the TimeRecord model with the following fields:
For the Athlete model, the property full_name was added.
Migration file generated with command
makemigrations
for TimeRecord model.Created
TimeRecordSerializer
based onModelSerializer
to display almost all the information about an the time record and added theevent_type_name
andathlete_full_name
fields.In this file, created the validation method validate_time to ensure the format for this field is valid [M:]S.mm.
Created a ModelViewSet named TimeRecordViewSet. Overrode the
list
method to add the parametersathlete_name
andevent_type_id
in order to use them as filters. Overrode theget_queryset
method to implement the filter logic in caseathlete_name
orevent_type_id
were provided.Added the following endpoint:
Added a router to generate the endpoints for TimeRecord.
A fixture file called
time_record.json
was created with multiple time record objects.Swagger
All new endpoints are accessible through Swagger. Each endpoint has been tested successfully, including listing all Time Records which shows all the record information and includes the athlete full name and event type name associated with the record. For listing, the records can be filtered by
athlete_name
andevent_type_id
. Whenathlete_name
parameter is provided, the time records for the athletes whose first name or last name start with the provided value are displayed. Whenevent_type_id
parameter is provided, the time records for the that specific event type are displayed.