mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
FEATURE: Show user fields when the user is signing up
This commit is contained in:
@ -33,6 +33,10 @@ class Site
|
||||
@groups ||= Group.order(:name).map { |g| {:id => g.id, :name => g.name}}
|
||||
end
|
||||
|
||||
def user_fields
|
||||
UserField.all
|
||||
end
|
||||
|
||||
def categories
|
||||
@categories ||= begin
|
||||
categories = Category
|
||||
|
@ -657,6 +657,18 @@ class User < ActiveRecord::Base
|
||||
result.empty? ? I18n.t("user.no_accounts_associated") : result.join(", ")
|
||||
end
|
||||
|
||||
def user_fields
|
||||
return @user_fields if @user_fields
|
||||
user_field_ids = UserField.pluck(:id)
|
||||
if user_field_ids.present?
|
||||
@user_fields = {}
|
||||
user_field_ids.each do |fid|
|
||||
@user_fields[fid.to_s] = custom_fields["user_field_#{fid}"]
|
||||
end
|
||||
end
|
||||
@user_fields
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def badge_grant
|
||||
|
@ -1,3 +1,3 @@
|
||||
class UserFieldSerializer < ApplicationSerializer
|
||||
attributes :id, :name, :field_type
|
||||
attributes :id, :name, :field_type, :editable
|
||||
end
|
||||
|
Reference in New Issue
Block a user