fix for meember role disabled fields and also role will delete all the attribute fields

This commit is contained in:
Harry Bomrah 2015-07-08 20:00:59 +08:00
parent 59a198005d
commit 93d66b5866
3 changed files with 40 additions and 10 deletions

View File

@ -236,9 +236,37 @@ class MembersController < ApplicationController
end
when 'role'
if !field['id'].blank?
field_data = member.attribute_values.find_by(:attribute_field_id=>field['id'],:key=>field['key']).get_field_value rescue {}
av = member.attribute_values.find_by(:attribute_field_id=>field['id'],:key=>field['key']) rescue nil
if !av.nil?
r = av.attribute_field.role rescue nil
if !r.nil?
if memeber.roles.include?(r)
field_data = av.get_field_value rescue {}
else
field_data = {}
end
else
field_data = {}
end
else
field_data = {}
end
else
field_data = member.attribute_values.find_by(:key=>field['key']).get_field_value rescue {}
av = member.attribute_values.find_by(:key=>field['key']) rescue nil
if !av.nil?
r = av.attribute_field.role rescue nil
if !r.nil?
if member.roles.include?(r)
field_data = av.get_field_value rescue {}
else
field_data = {}
end
else
field_data = {}
end
else
field_data = {}
end
end
end
next if field_data.blank? or field_data['value'].blank?

View File

@ -22,7 +22,7 @@ module AttributeValuesHelper
end
def show_minguo_calendar(from_to=nil)
get_minguo
# get_minguo
case from_to
when :to
@ -96,12 +96,14 @@ module AttributeValuesHelper
def get_date_by_format(from_to = nil)
case I18n.locale
when :zh_tw
case
when self.member_profile_field["typeC"]["calendar"] == "west_calendar"
show_west_calender(from_to)
when self.member_profile_field["typeC"]["calendar"] == "tw_calendar"
show_minguo_calendar(from_to)
end #case self.member_profile_field["typeC"]["calendar"]
# case
# when self.member_profile_field["typeC"]["calendar"] == "west_calendar"
# show_west_calender(from_to)
# when self.member_profile_field["typeC"]["calendar"] == "tw_calendar"
# show_minguo_calendar(from_to)
# end #case self.member_profile_field["typeC"]["calendar"]
show_west_calender(from_to)
when :en
show_west_calender(from_to)
end

View File

@ -10,7 +10,7 @@ class Role
has_and_belongs_to_many :member_profiles
has_many :authorizations
has_many :attribute_fields
has_many :attribute_fields, dependent: :destroy
accepts_nested_attributes_for :attribute_fields
has_many :role_statuses, dependent: :destroy