Introduced a new parameter named group_id in the list function of AthleteView.
Overrode the get_queryset function to detect whether group_id was provided. If group_id is provided, the corresponding group is obtained (a validation error occurs if the group does not exist), and the query set is filtered by gender, min_age, and max_age. An annotation was added to calculate the age of each athlete.
Swagger
I was able to filter by group successfully.
As of today, the ages of athletes in the fixture file are as follows:
This PR resolves issue #63
Implementation
backend/api/views/AthleteView.py
group_id
in thelist
function ofAthleteView
.get_queryset
function to detect whethergroup_id
was provided. Ifgroup_id
is provided, the corresponding group is obtained (a validation error occurs if the group does not exist), and the query set is filtered bygender
,min_age
, andmax_age
. An annotation was added to calculate the age of each athlete.Swagger
I was able to filter by group successfully.
As of today, the ages of athletes in the fixture file are as follows: