fix members_controller in app/controllers/.
This commit is contained in:
parent
00d1af4260
commit
4805a1e34c
|
@ -69,21 +69,25 @@ class MembersController < ApplicationController
|
|||
|
||||
if params[:tag].blank?
|
||||
MemberProfile.not_in(:role_status_ids.in=>role_status_ids).where(:role_ids.in=>[role['id']]).collect do |profile|
|
||||
if profile.user.nil?
|
||||
member_profiles << get_member_data(profile, fields_to_show)
|
||||
elsif profile.user.approved
|
||||
member_profiles << get_member_data(profile, fields_to_show)
|
||||
if profile.user.nil? || profile.user.approved
|
||||
get_member_data_return = get_member_data(profile, fields_to_show)
|
||||
if !get_member_data_return.nil?
|
||||
member_profiles << get_member_data_return
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
tag = MemberTag.find(params[:tag]) rescue nil
|
||||
MemberProfile.not_in(:role_status_ids.in=>role_status_ids).where(:role_ids.in=>[role['id']], :member_tag_ids.in => [tag.id]).collect do |profile|
|
||||
if profile.user.nil?
|
||||
member_profiles << get_member_data(profile, fields_to_show)
|
||||
elsif profile.user.approved
|
||||
member_profiles << get_member_data(profile, fields_to_show)
|
||||
if !tag.nil?
|
||||
MemberProfile.not_in(:role_status_ids.in=>role_status_ids).where(:role_ids.in=>[role['id']], :member_tag_ids.in => [tag.id]).each do |profile|
|
||||
if profile.user.nil? || profile.user.approved
|
||||
get_member_data_return = get_member_data(profile, fields_to_show)
|
||||
if !get_member_data_return.nil?
|
||||
member_profiles << get_member_data_return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end if !tag.nil?
|
||||
end
|
||||
if member_sort_position
|
||||
member_profiles = member_profiles.sort_by{|data| (data['list_order'])} rescue member_profiles
|
||||
|
@ -113,10 +117,11 @@ class MembersController < ApplicationController
|
|||
end
|
||||
|
||||
mps.each do |member|
|
||||
if member.user.nil?
|
||||
member_profiles << get_member_data(member, fields_to_show)
|
||||
elsif member.user.approved
|
||||
member_profiles << get_member_data(member, fields_to_show)
|
||||
if member.user.nil? || member.user.approved
|
||||
get_member_data_return = get_member_data(member, fields_to_show)
|
||||
if !get_member_data_return.nil?
|
||||
member_profiles << get_member_data_return
|
||||
end
|
||||
end
|
||||
end
|
||||
if member_sort_position
|
||||
|
@ -128,13 +133,18 @@ class MembersController < ApplicationController
|
|||
|
||||
def get_member_data(member, fields_to_show)
|
||||
image = member.avatar.present? ? member.avatar.thumb.url : ActionController::Base.helpers.asset_path('member-pic.png')
|
||||
member_data_return = member_data(member, fields_to_show)
|
||||
if !member_data_return.nil? && (!member_data_return.empty? rescue false)
|
||||
{
|
||||
'profile_data'=>member_data(member, fields_to_show),
|
||||
'profile_data'=> member_data_return,
|
||||
'list_order' => member.position,
|
||||
'name' => member.name,
|
||||
'image'=>image,
|
||||
"link_to_show" => OrbitHelper.url_to_show(member.to_param)
|
||||
}
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
@ -374,6 +384,7 @@ class MembersController < ApplicationController
|
|||
if !field['id'].blank?
|
||||
next if !privacy_approved_status
|
||||
av = member.attribute_values.find_by(:attribute_field_id=>field['id'],:key=>field['key']) rescue nil
|
||||
av = member.attribute_values.find_by(:attribute_field_id=>field['id']) rescue nil if av.nil? #some role's key has been changed to sort number,so it doesn't work when searching field from using its key
|
||||
field_data = {"value" => " "}
|
||||
if !av.nil?
|
||||
r = av.attribute_field.role rescue nil
|
||||
|
@ -439,7 +450,7 @@ class MembersController < ApplicationController
|
|||
I18n.locale = @locale
|
||||
end
|
||||
if field['link_to_show']
|
||||
if field_data['value'] == ' ' #需jquery刪除空白欄位
|
||||
if field_data['value'] == ' ' #空白欄位
|
||||
field_data['value'] = "" #若無網站連結,刪除實驗室網站字樣
|
||||
field_data['title'] = "" #無網站連結,則不顯示
|
||||
elsif field_data['value'].include? 'href='
|
||||
|
@ -456,9 +467,10 @@ class MembersController < ApplicationController
|
|||
|
||||
field_data['title_class'] = "member-data-title-"+field['key'].underscore.gsub('_','-')
|
||||
field_data['value_class'] = "member-data-value-"+field['key'].underscore.gsub('_','-')
|
||||
next if field_data['value'] == "" || field_data['value'] == ' '
|
||||
if !field_data['title'].blank? && !field_data['value'].blank?
|
||||
profile_data.push(field_data)
|
||||
end
|
||||
end
|
||||
return profile_data
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue