Class: Decidim::Admin::ComponentPermissionsController

Inherits:
ResourcePermissionsController show all
Includes:
ComponentPathHelper
Defined in:
decidim-admin/app/controllers/decidim/admin/component_permissions_controller.rb

Overview

Controller that allows managing component and related resources permissions.

Instance Method Summary collapse

Methods included from ComponentPathHelper

#can_be_managed?, #main_component_path, #main_component_url, #manage_component_path

Methods inherited from ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#editObject


10
11
12
13
14
15
16
17
# File 'decidim-admin/app/controllers/decidim/admin/component_permissions_controller.rb', line 10

def edit
  enforce_permission_to :update, :component, component: component
  @permissions_form = PermissionsForm.new(
    permissions: permission_forms
  )

  render template: "decidim/admin/resource_permissions/edit"
end

#updateObject


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'decidim-admin/app/controllers/decidim/admin/component_permissions_controller.rb', line 19

def update
  enforce_permission_to :update, :component, component: component
  @permissions_form = PermissionsForm.from_params(params)

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

    on(:invalid) do
      flash.now[:alert] = t("component_permissions.update.error", scope: "decidim.admin")
      render action: :edit
    end
  end
end