backend/api/models.py
Create Site model with the following fields:
Name (Unique and case-insensitive constraints were added after the initial migrations)
Num_lanes
Pool_name
Len_unit (Added a sub-class to manage choices for Len_unit)
Added a sub clase to manage the choices for Len_unit
backend/api/migrations/0004_site.py
Initial migration to create the Site model. Note: In this migration, the Name field does not have Unique and case-insensitive characteristics.
backend/api/migrations/0005_add_collation_unique_to_name_site.py
In this migration, Unique and case-insensitive characteristics were manually added to the Name field.
backend/api/serializers/SiteSerializer.py
Created a generic serializer with Site as the model.
backend/api/views/SiteView.py
Created a view for Site with:
Ordering by name
Search by name
Sorting by name
backend/api/urls.py
Added a router to generate the endpoints.
backend/api/fixtures/setup_data.json
Added data for the example site.
Swagger
The endpoints are accessible through Swagger:
After executing the migrations and loading the setup file, the example site is visible:
I successfully performed operations such as creating new sites, deleting them, listing them, and utilizing the sort and search functions.
This PR addresses issue #14
Implementation
Added a sub clase to manage the choices for Len_unit
backend/api/migrations/0004_site.py Initial migration to create the Site model. Note: In this migration, the Name field does not have Unique and case-insensitive characteristics.
backend/api/migrations/0005_add_collation_unique_to_name_site.py In this migration, Unique and case-insensitive characteristics were manually added to the Name field.
backend/api/serializers/SiteSerializer.py Created a generic serializer with Site as the model.
backend/api/views/SiteView.py Created a view for Site with:
backend/api/urls.py Added a router to generate the endpoints.
backend/api/fixtures/setup_data.json
Added data for the example site.
Swagger
The endpoints are accessible through Swagger:
After executing the migrations and loading the setup file, the example site is visible:
I successfully performed operations such as creating new sites, deleting them, listing them, and utilizing the sort and search functions.