Sha256: 67ce657508e21f132f284c37239446a3b2b7f21047e1f37030eac806e563456a

Contents?: true

Size: 622 Bytes

Versions: 10

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A form object used to promote managed users from the admin dashboard.
    #
    class ManagedUserPromotionForm < Form
      attribute :email, String

      validates :email, presence: true, 'valid_email_2/email': { disposable: true }
      validate :unique_email

      private

      def unique_email
        return true if Decidim::User.where(
          organization: context.current_organization,
          email: email
        ).where.not(id: context.current_user.id).empty?
        errors.add :email, :taken
        false
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-admin-0.18.1 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.17.2 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.18.0 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.17.1 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.16.1 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.17.0 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.16.0 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.15.2 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.15.1 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.15.0 app/forms/decidim/admin/managed_user_promotion_form.rb