Sha256: 3492c2a2309a6ee15c2d70521727cb39d8607dd29dec84f92a4bb2abca71ad0a

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require "decidim/version"
require "decidim/cdtb/tasks"

namespace :cdtb do
  namespace :participatory_spaces do
    desc <<~EODESC
      Add content blocks to a participatory processes
    EODESC
    task :add_content_blocks, [:content_block_names] => :environment do |_task, args|
      unless Decidim.version >= "0.28"
        puts "This command is only compatible with Decidim v0.28 or higher"
        exit(-1)
      end

      content_block_names = args[:content_block_names].split

      puts "\n Select participatory spaces you want to add the content blocks: #{content_block_names}"
      puts "\n 1. Decidim::ParticipatoryProcess"
      puts "\n 2. Decidim::Assembly"
      puts "\n 3. All"

      selected_option = $stdin.gets.chomp
      puts selected_option

      case selected_option
      when "1"
        processed_models = [
          "Decidim::ParticipatoryProcess"
        ].freeze
      when "2"
        processed_models = [
          "Decidim::Assembly"
        ].freeze
      when "3"
        processed_models = [
          "Decidim::ParticipatoryProcess",
          "Decidim::Assembly"
        ].freeze
      else
        return "Please, select an option"
      end

      adder = ::Decidim::Cdtb::ParticipatorySpaces::AddContentBlocks.new(processed_models, content_block_names)
      adder.execute!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-cdtb-0.3.0 lib/tasks/participatory_spaces.rake