Class: Decidim::Debates::Admin::DebatesController
- Inherits:
-
ApplicationController
- Object
- Admin::Components::BaseController
- ApplicationController
- Decidim::Debates::Admin::DebatesController
- Defined in:
- app/controllers/decidim/debates/admin/debates_controller.rb
Overview
This controller allows an admin to manage debates from a Participatory Space
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/decidim/debates/admin/debates_controller.rb', line 22 def create :create, :debate @form = form(Decidim::Debates::Admin::DebateForm).from_params(params, current_component:) CreateDebate.call(@form) do on(:ok) do flash[:notice] = I18n.t("debates.create.success", scope: "decidim.debates.admin") redirect_to debates_path end on(:invalid) do flash.now[:alert] = I18n.t("debates.create.invalid", scope: "decidim.debates.admin") render action: "new" end end end |
#destroy ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/decidim/debates/admin/debates_controller.rb', line 64 def destroy (:delete, :debate, debate:) debate.destroy! flash[:notice] = I18n.t("debates.destroy.success", scope: "decidim.debates.admin") redirect_to debates_path end |
#edit ⇒ Object
40 41 42 43 44 |
# File 'app/controllers/decidim/debates/admin/debates_controller.rb', line 40 def edit (:update, :debate, debate:) @form = form(Decidim::Debates::Admin::DebateForm).from_model(debate) end |
#index ⇒ Object
12 13 14 |
# File 'app/controllers/decidim/debates/admin/debates_controller.rb', line 12 def index :read, :debate end |
#new ⇒ Object
16 17 18 19 20 |
# File 'app/controllers/decidim/debates/admin/debates_controller.rb', line 16 def new :create, :debate @form = form(Decidim::Debates::Admin::DebateForm).instance end |
#update ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/decidim/debates/admin/debates_controller.rb', line 46 def update (:update, :debate, debate:) @form = form(Decidim::Debates::Admin::DebateForm).from_params(params, current_component:) UpdateDebate.call(@form, debate) do on(:ok) do flash[:notice] = I18n.t("debates.update.success", scope: "decidim.debates.admin") redirect_to debates_path end on(:invalid) do flash.now[:alert] = I18n.t("debates.update.invalid", scope: "decidim.debates.admin") render action: "edit" end end end |