Sha256: f81cf01a1ca788bae7444576d16b699b22f0318037248965a9cd401a26a1d8bf

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    # Controller in charge of managing committee membership
    class CommitteeRequestsController < Decidim::ApplicationController
      include Decidim::Initiatives::NeedsInitiative

      helper Decidim::ActionAuthorizationHelper
      helper InitiativeHelper

      include Decidim::Initiatives::ActionAuthorization

      # GET /initiatives/:initiative_id/committee_requests/new
      def new
        authorize! :request_membership, current_initiative
      end

      # GET /initiatives/:initiative_id/committee_requests/spawn
      def spawn
        authorize! :request_membership, current_initiative

        SpawnCommitteeRequest.call(current_initiative, current_user) do
          on(:ok) do
            redirect_to initiatives_path, flash: {
              notice: I18n.t(
                "success",
                scope: %w(decidim initiatives committee_requests spawn)
              )
            }
          end

          on(:invalid) do |request|
            redirect_to initiatives_path, flash: {
              error: request.errors.full_messages.to_sentence
            }
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-initiatives-0.11.2 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.11.1 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.11.0.pre1 app/controllers/decidim/initiatives/committee_requests_controller.rb