Class: Decidim::Consultations::Admin::ConsultationsController
- Inherits:
-
ApplicationController
- Object
- Admin::ApplicationController
- ApplicationController
- Decidim::Consultations::Admin::ConsultationsController
- Includes:
- Filterable
- Defined in:
- app/controllers/decidim/consultations/admin/consultations_controller.rb
Overview
Controller in charge of managing consultation related requests
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/consultations.
-
#edit ⇒ Object
GET /admin/consultations/:slug/edit.
-
#index ⇒ Object
GET /admin/consultations.
-
#new ⇒ Object
GET /admin/consultations/new.
-
#results ⇒ Object
GET /admin/consultations/:slug/results.
-
#update ⇒ Object
PUT /admin/consultations/:slug.
Instance Method Details
#create ⇒ Object
POST /admin/consultations
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/decidim/consultations/admin/consultations_controller.rb', line 24 def create :create, :consultation @form = consultation_form.from_params(params) CreateConsultation.call(@form) do on(:ok) do flash[:notice] = I18n.t("consultations.create.success", scope: "decidim.admin") redirect_to consultations_path end on(:invalid) do flash.now[:alert] = I18n.t("consultations.create.error", scope: "decidim.admin") render :new end end end |
#edit ⇒ Object
GET /admin/consultations/:slug/edit
42 43 44 45 46 |
# File 'app/controllers/decidim/consultations/admin/consultations_controller.rb', line 42 def edit :update, :consultation, consultation: current_consultation @form = consultation_form.from_model(current_consultation) render layout: "decidim/admin/consultation" end |
#index ⇒ Object
GET /admin/consultations
12 13 14 15 |
# File 'app/controllers/decidim/consultations/admin/consultations_controller.rb', line 12 def index :read, :consultation @consultations = filtered_collection end |
#new ⇒ Object
GET /admin/consultations/new
18 19 20 21 |
# File 'app/controllers/decidim/consultations/admin/consultations_controller.rb', line 18 def new :create, :consultation @form = consultation_form.instance end |
#results ⇒ Object
GET /admin/consultations/:slug/results
69 70 71 72 |
# File 'app/controllers/decidim/consultations/admin/consultations_controller.rb', line 69 def results :read, :consultation, consultation: current_consultation render layout: "decidim/admin/consultation" end |
#update ⇒ Object
PUT /admin/consultations/:slug
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/decidim/consultations/admin/consultations_controller.rb', line 49 def update :update, :consultation, consultation: current_consultation @form = consultation_form .from_params(params.except(:slug), consultation_id: current_consultation.id) UpdateConsultation.call(current_consultation, @form) do on(:ok) do |consultation| flash[:notice] = I18n.t("consultations.update.success", scope: "decidim.admin") redirect_to edit_consultation_path(consultation) end on(:invalid) do flash.now[:alert] = I18n.t("consultations.update.error", scope: "decidim.admin") render :edit, layout: "decidim/admin/consultation" end end end |