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