app/controllers/scrivito/workspaces_controller.rb in scrivito_sdk-0.41.1 vs app/controllers/scrivito/workspaces_controller.rb in scrivito_sdk-0.42.0
- old
+ new
@@ -1,13 +1,14 @@
module Scrivito
class WorkspacesController < WebserviceController
+ around_action :authorize_workspace_create, only: :create
around_action :authorize_current_workspace_read, only: :show
around_action :authorize_current_workspace_write, only: [:update, :destroy, :rebase]
around_action :authorize_current_workspace_publish, only: [:check, :publish]
def index
- @workspaces = Workspace.all.select do |workspace|
+ @workspaces = all_workspaces.select do |workspace|
can_user_access_workspace?(:read, workspace)
end
end
def show
@@ -76,10 +77,14 @@
def publish_checker
Workspace::PublishChecker.new(current_workspace, scrivito_user)
end
+ def authorize_workspace_create(&block)
+ authorize_workspace_access(:create, :workspace, &block)
+ end
+
def authorize_current_workspace_read(&block)
authorize_current_workspace_access(:read, &block)
end
def authorize_current_workspace_write(&block)
@@ -146,8 +151,14 @@
raise ClientError.new(
'Content state id changed',
400,
'precondition_not_met.workspace.publish.content_state_id'
)
+ end
+
+ def all_workspaces
+ CmsRestApi.get('/workspaces')['results'].map do |raw_data|
+ Workspace.new(WorkspaceDataFromRestApi.new(raw_data))
+ end
end
end
end