MarisiaS / SMM

0 stars 0 forks source link

BE-Registering sites #40

Closed MarisiaS closed 8 months ago

MarisiaS commented 8 months ago

This PR addresses issue #14

Implementation

  1. backend/api/models.py Create Site model with the following fields:

Added a sub clase to manage the choices for Len_unit

  1. 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.

  2. 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.

  3. backend/api/serializers/SiteSerializer.py Created a generic serializer with Site as the model.

  4. backend/api/views/SiteView.py Created a view for Site with:

  1. backend/api/urls.py Added a router to generate the endpoints.

  2. backend/api/fixtures/setup_data.json

Added data for the example site.

Swagger

The endpoints are accessible through Swagger:

image

After executing the migrations and loading the setup file, the example site is visible:

image

I successfully performed operations such as creating new sites, deleting them, listing them, and utilizing the sort and search functions.