First draft API to delete collections (#37117)

This commit is contained in:
David Roetzel
2025-12-04 14:47:23 +01:00
committed by GitHub
parent 5a7a4fff11
commit 9921fa1af7
3 changed files with 45 additions and 3 deletions

View File

@@ -13,11 +13,12 @@ class Api::V1Alpha::CollectionsController < Api::BaseController
before_action :require_user!, only: [:create]
before_action :set_collection, only: [:show, :update, :destroy]
after_action :verify_authorized
def show
cache_if_unauthenticated!
@collection = Collection.find(params[:id])
authorize @collection, :show?
render json: @collection, serializer: REST::CollectionSerializer
@@ -32,7 +33,6 @@ class Api::V1Alpha::CollectionsController < Api::BaseController
end
def update
@collection = Collection.find(params[:id])
authorize @collection, :update?
@collection.update!(collection_update_params) # TODO: Create a service for this to federate changes
@@ -40,8 +40,20 @@ class Api::V1Alpha::CollectionsController < Api::BaseController
render json: @collection, serializer: REST::CollectionSerializer
end
def destroy
authorize @collection, :destroy?
@collection.destroy
head 200
end
private
def set_collection
@collection = Collection.find(params[:id])
end
def collection_creation_params
params.permit(:name, :description, :sensitive, :discoverable, :tag_name, account_ids: [])
end