member for THU

This commit is contained in:
Matthew K. Fu JuYuan authored and chris committed 2012-10-26 11:19:56 +08:00
1 parent 579c7b5e81
commit 0a1a9d2c2e
14 files changed
+162 -123

No files matched your search

+1
View File
@@ -18,6 +18,7 @@ class AttributeField
field :locale_title, localize: true
field :neutral_title
field :neutral_for
belongs_to :attribute
# belongs_to :role
+19 -8
View File
@@ -30,17 +30,20 @@ class AttributeValue
when "text_field"
self.attribute_field.locale ? self[locale] : self[:value]
when "select"
self.attribute_field.markup_value[self[:value]][locale.to_s] || NoData
markup_values = eval(self.attribute_field.markup_value)
markup_values[self[:value]][locale.to_s] rescue 'NoData'
when "text_area"
#self[:value]
self.attribute_field.locale ? self[locale] : self[:value]
when "date"
Date.new(self[:value]["(1i)"].to_i,self[:value]["(2i)"].to_i,self[:value]["(3i)"].to_i)
Date.new(self[:value]["(1i)"].to_i,self[:value]["(2i)"].to_i,self[:value]["(3i)"].to_i) rescue nil
when "addr"
self[:value]
when "radio_button"
self[:value]
markup_values = eval(self.attribute_field.markup_value)
markup_values[self[:value].first[0]][locale.to_s]
when "checkbox"
self[:value]
markup_values = eval(self.attribute_field.markup_value)
self[:value].keys.collect{|key| markup_values[key][locale.to_s] }.join(",")
when "date_durnation"
self[:value]
else
@@ -49,10 +52,18 @@ class AttributeValue
end
def get_values
if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"]
return Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}]
unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup )
if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"]
return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}]
else
return get_value_by_locale("")
end
else
return self[:value]
if self.attribute_field.markup == "select"
self[:value]
else
self[:value].keys
end
end
end
+15
View File
@@ -35,10 +35,22 @@ class User
before_create :initialize_desktop
before_save :check_status_record
before_save :save_roles
scope :remote_account, where(:nccu_id.ne => nil)
validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique")
# def new_attribute_values=(vars)
# binding.pry
# end
# def new_attribute_values(vars)
# binding.pry
# end
def rebuild_sub_roles_from_attribute_values!(attribute_values)
# attribute_fields = AttributeField.find attribute_values.collect{|t| t[1][:attribute_field_id]}
# self.sub_roles = attribute_fields.collect{|t| t.attribute if t.attribute.is_a? SubRole}.compact.uniq
end
def set_sub_role(sub_role_id,status_id)
self.sub_roles << SubRole.find(sub_role_id)
@@ -131,6 +143,9 @@ class User
end
protected
def save_roles
self.roles = self.sub_roles.collect{|t| t.role}.uniq
end
def check_status_record
roles = sub_roles.collect{|t| t.role}.uniq #get all role from sub_roles