Sha256: 8d487011a4e523c91d47a46946edcf976518396e451159326fbdc206cf85c00e

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

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

      helper InitiativeHelper
      helper Decidim::ActionAuthorizationHelper

      layout "layouts/decidim/application"

      # GET /initiatives/:initiative_id/committee_requests/new
      def new
        enforce_permission_to :request_membership, :initiative, initiative: current_initiative
      end

      # GET /initiatives/:initiative_id/committee_requests/spawn
      def spawn
        enforce_permission_to :request_membership, :initiative, initiative: 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

9 entries across 9 versions & 1 rubygems

Version Path
decidim-initiatives-0.16.1 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.16.0 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.15.2 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.15.1 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.15.0 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.14.4 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.14.3 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.14.2 app/controllers/decidim/initiatives/committee_requests_controller.rb
decidim-initiatives-0.14.1 app/controllers/decidim/initiatives/committee_requests_controller.rb