Sha256: eb50ab3236420a92f51313bccf043c7360cac25419e52e6f6ec22a52a58b0410

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    module Admin
      module ValuationAssignmentsControllerOverride
        extend ActiveSupport::Concern

        included do
          def create
            enforce_permission_to :assign_to_valuator, :proposals
            @form = form(Admin::ValuationAssignmentForm).from_params(params)
            Admin::AssignProposalsToValuator.call(@form) do
              on(:ok) do |_proposal|
                flash[:notice] = I18n.t("valuation_assignments.create.success", scope: "decidim.proposals.admin")
                redirect_to after_add_evaluator_url
              end

              on(:invalid) do
                flash.now[:alert] = I18n.t("valuation_assignments.create.invalid", scope: "decidim.proposals.admin")
                redirect_to after_add_evaluator_url
              end
            end
          end

          def after_add_evaluator_url
            return request.referer if request.referer.present? && request.referer =~ %r{manage/proposals/[0-9]+}

            EngineRouter.admin_proxy(current_component).root_path
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-reporting_proposals-0.5.1 app/controllers/concerns/decidim/proposals/admin/valuation_assignments_controller_override.rb
decidim-reporting_proposals-0.5.0 app/controllers/concerns/decidim/proposals/admin/valuation_assignments_controller_override.rb
decidim-reporting_proposals-0.4.2 app/controllers/concerns/decidim/proposals/admin/valuation_assignments_controller_override.rb