Sha256: e89579e13186bfb1126cca1ec17cb4973ef9ad0764e471c452f1244ce07c3ae6

Contents?: true

Size: 1.33 KB

Versions: 32

Compression:

Stored size: 1.33 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(
            attachment: form(AttachmentForm).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

32 entries across 32 versions & 2 rubygems

Version Path
decidim-proposals-0.8.4 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.8.3 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.8.2 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.8.1 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.8.0 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.7.4 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.7.3 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.7.2 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.7.1 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.7.0 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.6.8 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.6.8 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.6.7 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.6.7 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.6.6 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.6.6 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.6.5 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.6.5 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-proposals-0.6.4 app/controllers/decidim/proposals/admin/proposals_controller.rb
decidim-0.6.4 decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb