Class: Decidim::Admin::ResourcePermissionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/decidim/admin/resource_permissions_controller.rb

Overview

Controller that allows managing resource permissions.

Direct Known Subclasses

ComponentPermissionsController

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Instance Method Details

#editObject



12
13
14
15
16
# File 'app/controllers/decidim/admin/resource_permissions_controller.rb', line 12

def edit
  @permissions_form = PermissionsForm.new(
    permissions: permission_forms
  )
end

#updateObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/decidim/admin/resource_permissions_controller.rb', line 18

def update
  @permissions_form = PermissionsForm.from_params(params).with_context(current_organization: current_organization)

  UpdateResourcePermissions.call(@permissions_form, resource) do
    on(:ok) do
      flash[:notice] = t("resource_permissions.update.success", scope: "decidim.admin")
      redirect_to return_path
    end

    on(:invalid) do
      render action: :edit
    end
  end
end