app/controllers/scrivito/workspaces_controller.rb in scrivito_sdk-1.3.1 vs app/controllers/scrivito/workspaces_controller.rb in scrivito_sdk-1.4.0.rc1

- old
+ new

@@ -1,19 +1,15 @@ module Scrivito class WorkspacesController < WebserviceController def self.restrict_access_to(action_name, require_permission:) around_action only: action_name do |_, block| - subject = params.has_key?(:id) ? current_workspace : :workspace + subject = params.key?(:id) ? current_workspace : :workspace authorize_workspace_access(require_permission, subject, &block) end end - restrict_access_to :create, require_permission: :create restrict_access_to :show, require_permission: :read - restrict_access_to :rename, require_permission: :write - restrict_access_to :memberships, require_permission: :invite_to - restrict_access_to :destroy, require_permission: :delete restrict_access_to :rebase, require_permission: :write restrict_access_to :check, require_permission: :publish restrict_access_to :publish, require_permission: :publish def index @@ -22,37 +18,10 @@ end def show end - def create - create_workspace_params = workspace_params.dup - unless scrivito_user.system_user? - create_workspace_params.deep_merge!(memberships: {scrivito_user.id => {role: 'owner'}}) - end - result = task_unaware_request(:post, '/workspaces', workspace: create_workspace_params) - - handle_if_task(result) do - @workspace_result = result - end - end - - def rename - current_workspace.update(workspace_params.slice(:title)) - render_empty_json - end - - def memberships - current_workspace.update(workspace_params.slice(:memberships)) - render_empty_json - end - - def destroy - current_workspace.destroy - render_empty_json - end - def rebase @task = task_unaware_request(:put, current_workspace_backend_path('/rebase'), {})['task'] render :task end @@ -104,18 +73,9 @@ end def certificates_param assert_valid_certificates_param params[:certificates] - end - - def handle_if_task(result) - if result['task'].present? - @task = result['task'] - render :task - else - yield result - end end def assert_workspace_is_not_outdated if current_workspace.outdated? raise ClientError.new(