Sha256: b29617b0000eaf171f02a99fc24fdffa4c3a821d909bc5ad50ba74ca224fa3bb
Contents?: true
Size: 1013 Bytes
Versions: 13
Compression:
Stored size: 1013 Bytes
Contents
# frozen_string_literal: true module Decidim module Accountability module Admin # A command with all the business logic when an admin imports projects from # one component to accountability. class ImportProjectsToAccountability < Decidim::Command # Public: Initializes the command. # # form - A form object with the params. def initialize(form) @form = form end def call return broadcast(:invalid) unless @form.valid? ImportProjectsJob.perform_later(projects.pluck(:id), @form.current_component, @form.current_user) broadcast(:ok, projects.count) end private def projects Decidim::Budgets::Project.joins(:budget).selected.where( budget: { component: origin_component } ).reject { |item| @form.project_already_copied?(item) } end def origin_component @form.origin_component end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems