Mercurial > hg > soundsoftware-site
comparison app/controllers/users_controller.rb @ 193:90cc857e968a luisf
Merge from branch "feature_64"
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 07 Feb 2011 12:52:57 +0000 |
parents | f9fe5ef6156e |
children | 73ff0e6a11b1 |
comparison
equal
deleted
inserted
replaced
151:e5171a80c541 | 193:90cc857e968a |
---|---|
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 if @user.ssamr_user_detail.institution_id != nil | 57 |
58 @institution_name = Institution.find(@user.ssamr_user_detail.institution_id).name | 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 | |
59 end | 65 end |
60 end | 66 end |
61 | 67 |
62 # show projects based on current user visibility | 68 # show projects based on current user visibility |
63 @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current)) | 69 @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current)) |
83 | 89 |
84 @user = User.new(:language => Setting.default_language) | 90 @user = User.new(:language => Setting.default_language) |
85 @auth_sources = AuthSource.find(:all) | 91 @auth_sources = AuthSource.find(:all) |
86 | 92 |
87 @ssamr_user_details = SsamrUserDetail.new | 93 @ssamr_user_details = SsamrUserDetail.new |
88 | |
89 # default value | |
90 @selected_institution_id = 1 | |
91 | |
92 | |
93 end | 94 end |
94 | 95 |
95 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 } |
96 def create | 97 def create |
97 @notification_options = User::MAIL_NOTIFICATION_OPTIONS | 98 @notification_options = User::MAIL_NOTIFICATION_OPTIONS |
136 @user = User.find(params[:id]) | 137 @user = User.find(params[:id]) |
137 @notification_options = @user.valid_notification_options | 138 @notification_options = @user.valid_notification_options |
138 @notification_option = @user.mail_notification | 139 @notification_option = @user.mail_notification |
139 | 140 |
140 @ssamr_user_details = @user.ssamr_user_detail | 141 @ssamr_user_details = @user.ssamr_user_detail |
141 @selected_institution_id = @user.ssamr_user_detail.institution_id.to_i | 142 |
143 if @user.ssamr_user_detail == nil | |
144 @selected_institution_id = nil | |
145 else | |
146 @selected_institution_id = @user.ssamr_user_detail.institution_id.to_i | |
147 end | |
142 | 148 |
143 @auth_sources = AuthSource.find(:all) | 149 @auth_sources = AuthSource.find(:all) |
144 @membership ||= Member.new | 150 @membership ||= Member.new |
145 end | 151 end |
146 | 152 |
173 end | 179 end |
174 | 180 |
175 if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty? | 181 if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty? |
176 @ssamr_user_details.description = @user.ssamr_user_detail.description | 182 @ssamr_user_details.description = @user.ssamr_user_detail.description |
177 @ssamr_user_details.institution_id = @user.ssamr_user_detail.institution_id | 183 @ssamr_user_details.institution_id = @user.ssamr_user_detail.institution_id |
184 @ssamr_user_details.other_institution = @user.ssamr_user_detail.other_institution | |
185 @ssamr_user_details.institution_type = @user.ssamr_user_detail.institution_type | |
186 | |
178 else | 187 else |
179 @ssamr_user_details.description = params[:ssamr_user_details][:description] | 188 @ssamr_user_details.description = params[:ssamr_user_details][:description] |
180 @ssamr_user_details.institution_id = params[:ssamr_user_details][:institution_id] | 189 @ssamr_user_details.institution_id = params[:ssamr_user_details][:institution_id] |
181 @ssamr_user_details.save! | 190 @ssamr_user_details.other_institution = params[:ssamr_user_details][:other_institution] |
191 @ssamr_user_details.institution_type = params[:ssamr_user_details][:institution_type] | |
182 end | 192 end |
183 | 193 |
184 if @user.save | 194 if @user.save |
185 @user.pref.save | 195 @user.pref.save |
186 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) | 196 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) |