Sha256: 5e06e6610f67f43df70ecec328516f4980e952cf2fad038542b764b04c64159f

Contents?: true

Size: 754 Bytes

Versions: 14

Compression:

Stored size: 754 Bytes

Contents

# frozen_string_literal: true
require "decidim/translatable_attributes"

module Decidim
  module System
    # A form object used to update organizations from the system dashboard.
    #
    class UpdateOrganizationForm < Rectify::Form
      include TranslatableAttributes

      mimic :organization

      attribute :name, String
      attribute :host, String

      translatable_attribute :description, String

      validate :validate_organization_uniqueness

      private

      def validate_organization_uniqueness
        errors.add(:name, :taken) if Decidim::Organization.where(name: name).where.not(id: id).exists?
        errors.add(:host, :taken) if Decidim::Organization.where(host: host).where.not(id: id).exists?
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
decidim-system-0.0.1.alpha9 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.1.alpha9 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-system-0.0.1.alpha8 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.1.alpha8 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-system-0.0.1.alpha7 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.1.alpha7 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-system-0.0.1.alpha6 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.1.alpha6 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-system-0.0.1.alpha5 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.1.alpha5 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-system-0.0.1.alpha4 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.1.alpha4 decidim-system/app/forms/decidim/system/update_organization_form.rb
decidim-system-0.0.1.alpha3 app/forms/decidim/system/update_organization_form.rb
decidim-0.0.1.alpha3 decidim-system/app/forms/decidim/system/update_organization_form.rb