Class: Decidim::Plans::Admin::SectionsController

Inherits:
ApplicationController
  • Object
show all
Includes:
ApplicationHelper
Defined in:
app/controllers/decidim/plans/admin/sections_controller.rb

Overview

This controller allows admins to manage plans in a participatory process.

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  enforce_permission_to :create, :section
  @form = form(Admin::PlanSectionsForm).from_params(params)

  Admin::UpdateSections.call(@form, sections) do
    on(:ok) do
      flash[:notice] = I18n.t("update.success", scope: i18n_flashes_scope)
      redirect_to sections_url
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("update.invalid", scope: i18n_flashes_scope)
      render action: :index
    end
  end
end

#editObject



36
37
38
# File 'app/controllers/decidim/plans/admin/sections_controller.rb', line 36

def edit
  enforce_permission_to :edit, :section, section: section
end

#indexObject



14
15
16
17
# File 'app/controllers/decidim/plans/admin/sections_controller.rb', line 14

def index
  enforce_permission_to :create, :sections
  @form = form(Admin::PlanSectionsForm).from_model(sections)
end

#updateObject



40
41
42
# File 'app/controllers/decidim/plans/admin/sections_controller.rb', line 40

def update
  enforce_permission_to :edit, :section, section: section
end