Sha256: c8a7d1434f9881b4826d795617700006575483f958bd103c9a958efd87f7b579

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 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_method :proposals

        def new
          @form = form(ProposalForm).from_params({}, feature: current_feature)
        end

        def create
          @form = form(ProposalForm).from_params(params, feature: current_feature)

          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)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
decidim-proposals-0.0.1 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.0.1 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb