Sha256: 67924e482f50a287ab5da3c872fffb207d6d2930a623c8d23c86a431a32d2d8d

Contents?: true

Size: 872 Bytes

Versions: 14

Compression:

Stored size: 872 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module Admin
      # A form object used to copy a assemblies from the admin
      # dashboard.
      #
      class AssemblyCopyForm < Form
        include TranslatableAttributes

        translatable_attribute :title, String

        mimic :assembly

        attribute :slug, String
        attribute :copy_categories, Boolean
        attribute :copy_features, 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 OrganizationAssemblies.new(current_organization).query.where(slug: slug).where.not(id: id).any?

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
decidim-assemblies-0.9.3 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.9.2 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.9.1 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.9.0 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.8.4 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.8.3 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.8.2 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.8.1 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.8.0 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.7.4 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.7.3 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.7.2 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.7.1 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.7.0 app/forms/decidim/assemblies/admin/assembly_copy_form.rb