app/controllers/scrivito/workspaces_controller.rb in scrivito_sdk-1.4.3 vs app/controllers/scrivito/workspaces_controller.rb in scrivito_sdk-1.5.0.rc1
- old
+ new
@@ -5,57 +5,41 @@
subject = params.key?(:id) ? current_workspace : :workspace
authorize_workspace_access(require_permission, subject, &block)
end
end
- restrict_access_to :show, require_permission: :read
- restrict_access_to :rebase, require_permission: :write
- restrict_access_to :check, require_permission: :publish
- restrict_access_to :publish, require_permission: :publish
+ restrict_access_to :show, require_permission: :read
+ restrict_access_to :check, require_permission: :publish
+ restrict_access_to :publish_approval, require_permission: :publish
def index
@workspaces = Workspace.all.select(&method(:can_user_read_workspace?))
render :workspaces
end
def show
end
- def rebase
- @task = task_unaware_request(:put, current_workspace_backend_path('/rebase'), {})['task']
- render :task
- end
-
def check
assert_workspace_is_not_outdated unless current_workspace.auto_update?
@check_result = publish_checker.call(params[:from].to_i)
end
- def publish
+ def publish_approval
if valid_publish_request?
- @task = conditional_publish['task']
- render :task
+ @approval = current_workspace.api_request(:put, '/publish_approval',
+ if_content_state_id_equals: current_workspace.content_state_id,
+ user_id: scrivito_user.id)
else
raise_content_state_id_changed
end
rescue ScrivitoError => e
raise ClientError.new(e.message)
end
private
- delegate :task_unaware_request, to: CmsRestApi
-
- def current_workspace_backend_path(suffix)
- "/workspaces/#{current_workspace.id}#{suffix}"
- end
-
- def conditional_publish
- task_unaware_request(:put, current_workspace_backend_path('/publish'),
- if_content_state_id_equals: current_workspace.content_state_id)
- end
-
def valid_publish_request?
publish_checker.passing_certificates?(certificates_param)
end
def publish_checker
@@ -65,15 +49,10 @@
def current_workspace
@current_workspace ||= Workspace.find(params[:id])
end
helper_method :current_workspace
- def workspace_params
- assert_valid_workspace_params
- params[:workspace]
- end
-
def certificates_param
assert_valid_certificates_param
params[:certificates]
end
@@ -91,14 +70,9 @@
raise ClientError.new("Required parameter 'certificates' is missing.")
end
unless params[:certificates].is_a?(Array)
raise ClientError.new("Parameter 'certificates' is not an array.")
end
- end
-
- def assert_valid_workspace_params
- raise "Required parameter 'workspace' is missing." unless params[:workspace].present?
- raise "Parameter 'workspace' is not a hash." unless params[:workspace].is_a?(Hash)
end
def raise_content_state_id_changed
raise ClientError.new(
'Content state id changed',