comparison app/controllers/users_controller.rb @ 184:b46db3a8b1b4 cannam-pre-20110113-merge

Merge from branch "feature_55"
author Chris Cannam
date Thu, 03 Feb 2011 15:15:30 +0000
parents bc23796a7120
children 594ed6aef7bd
comparison
equal deleted inserted replaced
172:be1bccc405d9 184:b46db3a8b1b4
52 def show 52 def show
53 @user = User.find(params[:id]) 53 @user = User.find(params[:id])
54 54
55 if @user.ssamr_user_detail != nil 55 if @user.ssamr_user_detail != nil
56 @description = @user.ssamr_user_detail.description 56 @description = @user.ssamr_user_detail.description
57
58 if @user.ssamr_user_detail.institution_type != nil
59 # institution_type is true for listed institutions
60 if (@user.ssamr_user_detail.institution_type)
61 @institution_name = Institution.find(@user.ssamr_user_detail.institution_id).name
62 else
63 @institution_name = @user.ssamr_user_detail.other_institution
64 end
65 end
57 end 66 end
58 67
59 # show projects based on current user visibility 68 # show projects based on current user visibility
60 @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current)) 69 @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current))
61 70
80 89
81 @user = User.new(:language => Setting.default_language) 90 @user = User.new(:language => Setting.default_language)
82 @auth_sources = AuthSource.find(:all) 91 @auth_sources = AuthSource.find(:all)
83 92
84 @ssamr_user_details = SsamrUserDetail.new 93 @ssamr_user_details = SsamrUserDetail.new
85
86 end 94 end
87 95
88 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } 96 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
89 def create 97 def create
90 @notification_options = User::MAIL_NOTIFICATION_OPTIONS 98 @notification_options = User::MAIL_NOTIFICATION_OPTIONS
129 @user = User.find(params[:id]) 137 @user = User.find(params[:id])
130 @notification_options = @user.valid_notification_options 138 @notification_options = @user.valid_notification_options
131 @notification_option = @user.mail_notification 139 @notification_option = @user.mail_notification
132 140
133 @ssamr_user_details = @user.ssamr_user_detail 141 @ssamr_user_details = @user.ssamr_user_detail
142
143 @selected_institution_id = @user.ssamr_user_detail.institution_id.to_i
134 144
135 @auth_sources = AuthSource.find(:all) 145 @auth_sources = AuthSource.find(:all)
136 @membership ||= Member.new 146 @membership ||= Member.new
137 end 147 end
138 148
161 @ssamr_user_details = SsamrUserDetail.new() 171 @ssamr_user_details = SsamrUserDetail.new()
162 @user.ssamr_user_detail = @ssamr_user_details 172 @user.ssamr_user_detail = @ssamr_user_details
163 else 173 else
164 @ssamr_user_details = @user.ssamr_user_detail 174 @ssamr_user_details = @user.ssamr_user_detail
165 end 175 end
166 176
167
168 if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty? 177 if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty?
169 @ssamr_user_details.description = @user.ssamr_user_detail.description 178 @ssamr_user_details.description = @user.ssamr_user_detail.description
179 @ssamr_user_details.institution_id = @user.ssamr_user_detail.institution_id
180 @ssamr_user_details.other_institution = @user.ssamr_user_detail.other_institution
181 @ssamr_user_details.institution_type = @user.ssamr_user_detail.institution_type
182
170 else 183 else
171 @ssamr_user_details.description = params[:ssamr_user_details][:description] 184 @ssamr_user_details.description = params[:ssamr_user_details][:description]
185 @ssamr_user_details.institution_id = params[:ssamr_user_details][:institution_id]
186 @ssamr_user_details.other_institution = params[:ssamr_user_details][:other_institution]
187 @ssamr_user_details.institution_type = params[:ssamr_user_details][:institution_type]
172 @ssamr_user_details.save! 188 @ssamr_user_details.save!
173 end 189 end
174 190
175 if @user.save 191 if @user.save
176 @user.pref.save 192 @user.pref.save