*backend/api/serializers/SiteSerializer.py
Add the serializer method validate_name to check if the site name is unique. It throws a Validation Error if there is an existing site with the same name.
backend/api/views/SiteView.py
Added the patch method to the http_method_names in the site view.
In the list method, used the LimitOffsetPagination (setup in the settings) to return the serialized data paginated.
Swagger
Patch endpoint:
The patch endpoint for Site is now available in Swagger:
I updated the information for a site using this endpoint and confirmed the new site information is saved.
List endpoint:
The list(Get) endpoint is including the pagination information in the response:
Before
After
Duplicate site name:
When trying to post or patch a Site using an existing name, the response is now a Bad Request error (400 status code) with the appropriate message:
This PR addresses issue #44
Implementation
*backend/api/serializers/SiteSerializer.py Add the serializer method
validate_name
to check if the site name is unique. It throws a Validation Error if there is an existing site with the same name.backend/api/views/SiteView.py Added the patch method to the http_method_names in the site view. In the list method, used the LimitOffsetPagination (setup in the settings) to return the serialized data paginated.
Swagger
Patch endpoint:
The patch endpoint for Site is now available in Swagger:
I updated the information for a site using this endpoint and confirmed the new site information is saved.
List endpoint:
The list(Get) endpoint is including the pagination information in the response: Before
After
Duplicate site name:
When trying to post or patch a Site using an existing name, the response is now a Bad Request error (400 status code) with the appropriate message: