Sha256: 435c2bf0bf76dfb03f103be8a677d3c140f724d17596a7fbe030ed4cb664699d

Contents?: true

Size: 818 Bytes

Versions: 18

Compression:

Stored size: 818 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
        validates :title, translatable_presence: true
        validate :slug, :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

18 entries across 18 versions & 2 rubygems

Version Path
decidim-assemblies-0.6.8 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-0.6.8 decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.6.7 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-0.6.7 decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.6.6 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-0.6.6 decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.6.5 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-0.6.5 decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.6.4 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-0.6.4 decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.6.3 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-0.6.3 decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.6.2 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-0.6.2 decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.6.1 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-0.6.1 decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-assemblies-0.6.0 app/forms/decidim/assemblies/admin/assembly_copy_form.rb
decidim-0.6.0 decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_copy_form.rb