Class: Decidim::Initiatives::InitiativesController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- ApplicationController
- ApplicationController
- Decidim::Initiatives::InitiativesController
- Includes:
- FormFactory, InitiativeSlug, NeedsInitiative, Orderable, SingleInitiativeType, TypeSelectorOptions, Paginable, FilterResource, ParticipatorySpaceContext
- Defined in:
- decidim-initiatives/app/controllers/decidim/initiatives/initiatives_controller.rb
Overview
This controller contains the logic regarding participants initiatives
Constant Summary
Constants included from Paginable
Constants included from RedesignLayout
RedesignLayout::FALLBACK_LAYOUT
Instance Method Summary collapse
-
#edit ⇒ Object
GET /initiatives/:slug/edit.
-
#index ⇒ Object
GET /initiatives.
- #print ⇒ Object
-
#send_to_technical_validation ⇒ Object
GET /initiatives/:id/send_to_technical_validation.
-
#show ⇒ Object
GET /initiatives/:id.
-
#update ⇒ Object
PUT /initiatives/:id.
Methods included from TranslationsHelper
empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?
Methods included from TranslatableAttributes
Methods included from InitiativeSlug
Methods inherited from ApplicationController
#permission_class_chain, #permission_scope, #permissions_context
Methods included from UserBlockedChecker
#check_user_block_status, #check_user_not_blocked
Methods included from NeedsSnippets
Methods included from HttpCachingDisabler
Methods included from HasStoredPath
#skip_store_location?, #store_current_location
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#edit ⇒ Object
GET /initiatives/:slug/edit
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/initiatives_controller.rb', line 71 def edit :edit, :initiative, initiative: current_initiative = form(AttachmentForm).from_model(current_initiative..first) @form = form(Decidim::Initiatives::InitiativeForm) .from_model( current_initiative, initiative: current_initiative ) @form. = render layout: "decidim/initiative" end |
#index ⇒ Object
GET /initiatives
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/initiatives_controller.rb', line 34 def index :list, :initiative return unless search.result.blank? && params.dig("filter", "with_any_state") != %w(closed) @closed_initiatives ||= search_with(filter_params.merge(with_any_state: %w(closed))) if @closed_initiatives.result.present? params[:filter] ||= {} params[:filter][:with_any_state] = %w(closed) @forced_closed_initiatives = true @search = @closed_initiatives end end |
#print ⇒ Object
105 106 107 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/initiatives_controller.rb', line 105 def print :read, :initiative, initiative: current_initiative end |
#send_to_technical_validation ⇒ Object
GET /initiatives/:id/send_to_technical_validation
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/initiatives_controller.rb', line 55 def send_to_technical_validation :send_to_technical_validation, :initiative, initiative: current_initiative SendInitiativeToTechnicalValidation.call(current_initiative, current_user) do on(:ok) do redirect_to EngineRouter.main_proxy(current_initiative).initiatives_path(initiative_slug: nil), flash: { notice: I18n.t( "success", scope: "decidim.initiatives.admin.initiatives.edit" ) } end end end |
#show ⇒ Object
GET /initiatives/:id
50 51 52 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/initiatives_controller.rb', line 50 def show :read, :initiative, initiative: current_initiative end |
#update ⇒ Object
PUT /initiatives/:id
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/initiatives_controller.rb', line 85 def update :update, :initiative, initiative: current_initiative params[:id] = params[:slug] @form = form(Decidim::Initiatives::InitiativeForm) .from_params(params, initiative_type: current_initiative.type, initiative: current_initiative) UpdateInitiative.call(current_initiative, @form, current_user) do on(:ok) do |initiative| flash[:notice] = I18n.t("success", scope: "decidim.initiatives.update") redirect_to initiative_path(initiative) end on(:invalid) do flash.now[:alert] = I18n.t("error", scope: "decidim.initiatives.update") render :edit, layout: "decidim/initiative" end end end |