Sha256: 8025e48aa5a68aafdce952e6e571fe0ccbb37270d6e09026b267f451fb2a60d0

Contents?: true

Size: 967 Bytes

Versions: 13

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    module Admin
      # A form object used to copy a participatory processes from the admin
      # dashboard.
      #
      class ParticipatoryProcessCopyForm < Form
        include TranslatableAttributes

        translatable_attribute :title, String

        mimic :participatory_process

        attribute :slug, String
        attribute :copy_steps, Boolean
        attribute :copy_categories, Boolean
        attribute :copy_components, Boolean

        validates :slug, presence: true, format: { with: Decidim::ParticipatoryProcess.slug_format }
        validates :title, translatable_presence: true
        validate :slug_uniqueness

        private

        def slug_uniqueness
          return unless OrganizationParticipatoryProcesses.new(current_organization).query.where(slug:).where.not(id:).any?

          errors.add(:slug, :taken)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.29.1 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.28.4 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.29.0 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.28.3 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.29.0.rc4 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.29.0.rc3 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.29.0.rc2 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.29.0.rc1 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.28.2 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.28.1 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.28.0 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.28.0.rc5 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb
decidim-participatory_processes-0.28.0.rc4 app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb