Class: Decidim::ActionDelegator::Admin::PermissionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/decidim/action_delegator/admin/permissions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/decidim/action_delegator/admin/permissions_controller.rb', line 7

def create
  enforce_permission_to :update, :setting
  return redirect_to decidim_admin_action_delegator.settings_path unless setting&.consultation

  FixResourcePermissions.call(setting.consultation.questions) do
    on(:ok) do
      notice = I18n.t("permissions.update.success", scope: "decidim.action_delegator.admin")
      redirect_to decidim_admin_action_delegator.settings_path, notice: notice
    end

    on(:invalid) do |_error|
      flash.now[:error] = I18n.t("permissions.update.error", scope: "decidim.action_delegator.admin")
      render :new
    end
  end
end

#syncObject



24
25
26
27
28
29
30
# File 'app/controllers/decidim/action_delegator/admin/permissions_controller.rb', line 24

def sync
  enforce_permission_to :update, :setting

  SyncParticipantsJob.perform_later(setting)
  notice = I18n.t("permissions.sync.started", scope: "decidim.action_delegator.admin")
  redirect_to decidim_admin_action_delegator.settings_path, notice: notice
end