Fixing bugs

This commit is contained in:
chris 2012-11-05 11:30:15 +08:00
parent 6783844937
commit 58d4554b0b
3 changed files with 18 additions and 17 deletions

View File

@ -33,14 +33,10 @@ class Admin::UsersNewInterfaceController < ApplicationController
@student_data = [] @student_data = []
@staff_data = [] @staff_data = []
attribute_values = @user.attribute_values
attribute_values = @user.attribute_values.reject{|att_val|
# binding.pry if(att_val.id.to_s == '507fa1295789b52a540000e0')
!att_val.attribute_field.locale and (att_val.attribute_field.neutral_for != I18n.locale.to_s)
}
attribute_values.each{|att_val| attribute_values.each{|att_val|
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale)}) if att_val.attribute_field.attribute.key=="profile" rescue false binding.pry if att_val.id.to_s == '5052dab52b5c49ae9d000006'
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" rescue false
} }

View File

@ -35,7 +35,12 @@ class AttributeField
end end
def locale def locale
(get_data["locale"] == "true" ? true : false) rescue false default = true
if get_data["locale"].nil?
return default
else
(get_data["locale"] == "true" ? true : false) rescue default
end
end end
def self_defined_markup_options? def self_defined_markup_options?

View File

@ -17,7 +17,7 @@ class AttributeValue
def data_proc def data_proc
# binding.pry # binding.pry
# binding.pry if self.attribute_field.markup == 'radio_button' # binding.pry if self.attribute_field.markup == 'radio_button'
if self.attribute_field.locale # if self.attribute_field
case self.attribute_field.markup case self.attribute_field.markup
when 'text_field','text_area' when 'text_field','text_area'
# binding.pry # binding.pry
@ -38,7 +38,7 @@ class AttributeValue
when 'checkbox' when 'checkbox'
self["val"] = self[:temp_data].keys rescue {} self["val"] = self[:temp_data].keys rescue {}
end #end of case end #end of case
end # end #of if self.attribute_field
self.unset('temp_data') self.unset('temp_data')
end end
@ -75,26 +75,26 @@ class AttributeValue
case self.attribute_field.markup case self.attribute_field.markup
when "text_field" when "text_field"
self.attribute_field.locale ? self.value[locale.to_s] : self.value self.attribute_field.locale ? self[locale.to_s] : self.value
when "select" when "select"
markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : eval(self.attribute_field.markup_value) markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : eval(self.attribute_field.markup_value)
markup_values[self.value][locale.to_s] rescue 'NoData' markup_values[self.value][locale.to_s] rescue 'NoData'
when "text_area" when "text_area"
self.attribute_field.locale ? self.value[locale.to_s] : self.value self.attribute_field.locale ? self[locale.to_s] : self.value
when "date" when "date"
Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil
when "addr" when "addr"
self.value self.value
when "radio_button" when "radio_button"
markup_values = eval(self.attribute_field.markup_value) markup_values = eval(self.attribute_field.markup_value)
markup_values[self.value][locale.to_s] markup_values[:value][locale.to_s]
when "checkbox" when "checkbox"
markup_values = eval(self.attribute_field.markup_value) markup_values = self.attribute_field.markup_value
self.value.collect{|key| markup_values[key][locale.to_s] }.join(",") self[:value].keys.collect{|key| markup_values[key][locale.to_s]}.join(",")
when "date_durnation" when "date_durnation"
self.value self.value
else else
self.attribute_field.locale ? self.value[locale.to_s] : self.value self.attribute_field.locale ? self[locale.to_s] : self.value
end end
end end