Class: Decidim::Initiatives::InitiativeSignaturesController

Inherits:
ApplicationController show all
Includes:
FormFactory, NeedsInitiative, Wicked::Wizard
Defined in:
decidim-initiatives/app/controllers/decidim/initiatives/initiative_signatures_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain, #permission_scope, #permissions_context

Methods included from RegistersPermissions

register_permissions

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject

POST /initiatives/:initiative_id/initiative_signatures


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'decidim-initiatives/app/controllers/decidim/initiatives/initiative_signatures_controller.rb', line 34

def create
  enforce_permission_to :vote, :initiative, initiative: current_initiative

  @form = form(Decidim::Initiatives::VoteForm)
          .from_params(
            initiative: current_initiative,
            signer: current_user
          )

  VoteInitiative.call(@form) do
    on(:ok) do
      current_initiative.reload
      render :update_buttons_and_counters
    end

    on(:invalid) do
      render :error_on_vote, status: :unprocessable_entity
    end
  end
end

#showObject

GET /initiatives/:initiative_id/initiative_signatures/:step


22
23
24
25
# File 'decidim-initiatives/app/controllers/decidim/initiatives/initiative_signatures_controller.rb', line 22

def show
  enforce_permission_to :sign_initiative, :initiative, initiative: current_initiative, signature_has_steps: signature_has_steps?
  send("#{step}_step", initiative_vote_form: session[:initiative_vote_form])
end

#updateObject

PUT /initiatives/:initiative_id/initiative_signatures/:step


28
29
30
31
# File 'decidim-initiatives/app/controllers/decidim/initiatives/initiative_signatures_controller.rb', line 28

def update
  enforce_permission_to :sign_initiative, :initiative, initiative: current_initiative, signature_has_steps: signature_has_steps?
  send("#{step}_step", params)
end