Sha256: 81c6e5e1695e065007953c333e64031ae7a6d1312c9dac18613307f31c52a32e

Contents?: true

Size: 623 Bytes

Versions: 39

Compression:

Stored size: 623 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

39 entries across 39 versions & 1 rubygems

Version Path
decidim-admin-0.26.10 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.9 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.8 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.7 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.5 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.4 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.3 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.2 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.1 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.0 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.0.rc2 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.26.0.rc1 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.25.2 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.25.1 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.25.0 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.25.0.rc4 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.25.0.rc3 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.25.0.rc2 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.25.0.rc1 app/forms/decidim/admin/managed_user_promotion_form.rb
decidim-admin-0.24.3 app/forms/decidim/admin/managed_user_promotion_form.rb