Sha256: 39392b42950f24d8369727347dfa8d1346329130cae5d82f6534b3bdf90e711d

Contents?: true

Size: 1.26 KB

Versions: 18

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    module Admin
      # This controller allows admins to manage proposals in a participatory process.
      class ProposalsController < Admin::ApplicationController
        helper Proposals::ApplicationHelper
        helper_method :proposals

        def new
          authorize! :create, Proposal
          @form = form(Admin::ProposalForm).from_params({})
        end

        def create
          authorize! :create, Proposal
          @form = form(Admin::ProposalForm).from_params(params)

          Admin::CreateProposal.call(@form) do
            on(:ok) do
              flash[:notice] = I18n.t("proposals.create.success", scope: "decidim.proposals.admin")
              redirect_to proposals_path
            end

            on(:invalid) do
              flash.now[:alert] = I18n.t("proposals.create.invalid", scope: "decidim.proposals.admin")
              render action: "new"
            end
          end
        end

        private

        def proposals
          @proposals ||= Proposal.where(feature: current_feature).page(params[:page]).per(15)
        end

        def proposal
          @proposal ||= Proposal.where(feature: current_feature).find(params[:id])
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
decidim-proposals-0.4.4 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.4.4 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.4.3 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.4.2 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.4.1 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.4.3 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.4.2 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.4.1 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.4.0 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.4.0 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.3.2 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.3.2 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.3.1 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.3.1 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.3.0 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.3.0 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.2.0 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.2.0 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb