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 = []
@staff_data = []
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 = @user.attribute_values
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
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
def self_defined_markup_options?

View File

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