Closed MarisiaS closed 6 months ago
@viriponce I have introduced a 'label' field to the model. However, I'm uncertain about the optimal approach. I'm considering three options:
Leave it as is right now: Retain the existing structure with both 'name' and 'label'.
Eliminate the name: Remove the 'name' function, keeping only the 'label' field.
Change name for label and label for name: Swap the names of the 'name' and 'label' .
What are your thoughts on these options?
@viriponce I have introduced a 'label' field to the model. However, I'm uncertain about the optimal approach. I'm considering three options:
- Leave it as is right now: Retain the existing structure with both 'name' and 'label'.
- Eliminate the name: Remove the 'name' function, keeping only the 'label' field.
- Change name for label and label for name: Swap the names of the 'name' and 'label' .
What are your thoughts on these options?
For future reference, We discussed the options and decided to eliminate name function, make coach_id and school_id required. The user will provide a name for the session.
This PR addresses issue #41
Implementation
Implemented Session model with the following fields:
days_of_week : An
ArrayField
with a maximum size of 7 andIntegerField
as the element type. Validators have been added to accept only 0 or 1 as elements. Note that ArrayField is available only for Postgres.time: A
TimeField
.coach: A foreign key linking
CustomUser
toSession
, allowing it to be null.school: A foreign key linking
School
toSession
, also allowed to be null.Introduced a
name
property to dynamically generate the session name based on days of the week and timeAfter creating the model, I ran the
makemigrations
command, resulting in the migration for the Session model.Developed a Model serializer for the Session model, incorporating validations for
days_of_week
:Added a
extend_schema_serializer
decorator to the serializer to provide examples of response and request data.Created a basic Model ViewSet for Session model.
Added a router to generate the endpoints for Session
Added data for 2 session objects.
I applied the migrations running the migrate command. Then load the fixture data with loaddata command.
Swagger
The endpoints are accessible through Swagger:
I tried each of the new endpoints successfully. I was able to create, delete, patch and get an session.
Posting a session without a
coach
and/orschool
is posible butdays_of_week
andtime
is required.