Sha256: 8d5e961147037e57b1e2ee30d43eef32f51c068a977408ff9661d4335b38cabb

Contents?: true

Size: 719 Bytes

Versions: 94

Compression:

Stored size: 719 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A form object used to officialize users from the admin dashboard.
    class OfficializationForm < Form
      include TranslatableAttributes

      translatable_attribute :officialized_as, String

      attribute :user_id, Integer

      validates :officialized_as, length: { maximum: 300 }

      validates :user, presence: true, if: ->(form) { form.user_id.present? }

      def map_model(user)
        self.officialized_as = user.officialized_as
        self.user_id = user.id
      end

      def user
        @user ||= Decidim::User.find_by(
          id: user_id,
          organization: current_organization
        )
      end
    end
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.28.4 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.27.9 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.29.0 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.28.3 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.27.8 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.29.0.rc4 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.29.0.rc3 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.29.0.rc2 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.29.0.rc1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.28.2 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.27.7 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.28.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.27.6 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.26.10 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.26.9 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.28.0 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.27.5 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.28.0.rc5 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.28.0.rc4 app/forms/decidim/admin/officialization_form.rb