diff --git a/program/views.py b/program/views.py index da5b0791e7441cc67bca712ad9f8232101f82adb..2b14a32726862c9b0b04241cca6fd797ebf7b936 100644 --- a/program/views.py +++ b/program/views.py @@ -611,18 +611,83 @@ class APIUserViewSet( return Response(serializer.data, status=status.HTTP_201_CREATED) +# done this way, because some of the properties have dots "." in their names +ImageCreateRequest = { + "multipart/form-data": { + "type": "object", + "properties": { + "image": { + "description": "The image file", + "type": "object", + }, + "alt_text": { + "description": "Alternate text for the image.", + "type": "string", + }, + "ppoi": { + "description": "The crop center point of the image.", + "type": "string", + }, + "licensing.credits": { + "description": "The credits for the image.", + "type": "string", + }, + "licensing.is_use_explicitly_granted_by_author": { + "description": "`True` if use is explicitly granted by author.", + "type": "boolean", + }, + "licensing.license_id": { + "description": "The `License` ID for the image.", + "type": "integer", + }, + }, + "required": ["image"], + } +} + +ImageUpdateRequest = { + "application/json": { + "type": "object", + "properties": { + "alt_text": { + "description": "Alternate text for the image.", + "type": "string", + }, + "ppoi": { + "description": "The crop center point of the image.", + "type": "string", + }, + "licensing.credits": { + "description": "The credits for the image.", + "type": "string", + }, + "licensing.is_use_explicitly_granted_by_author": { + "description": "`True` if use is explicitly granted by author.", + "type": "boolean", + }, + "licensing.license_id": { + "description": "The `License` ID for the image.", + "type": "integer", + }, + }, + } +} + + @extend_schema_view( - create=extend_schema(summary="Create a new image."), + create=extend_schema(request=ImageCreateRequest, summary="Create a new image."), destroy=extend_schema(summary="Delete an existing image."), list=extend_schema(summary="List all images."), partial_update=extend_schema( + description="Only `alt_text`, `ppoi`, `licensing.credits`, `licensing.is_use_explicitly_granted_by_author` and `licensing.license_id` can be updated.", + request=ImageUpdateRequest, summary="Partially update an existing image.", - description="Only `alt_text`, `credits`, and `ppoi` can be updated.", ), retrieve=extend_schema(summary="Retrieve a single image."), update=extend_schema( + description="Only `alt_text`, `ppoi`, `licensing.credits`, `licensing.is_use_explicitly_granted_by_author` and `licensing.license_id` can be updated.", + request=ImageUpdateRequest, summary="Update an existing image.", - description="Only `alt_text`, `credits`, and `ppoi` can be updated.", ), ) class APIImageViewSet(viewsets.ModelViewSet):