# HG changeset patch # User luisf # Date 1292590950 0 # Node ID d70a0b926135213073d9bffe553eb047d1af523e # Parent 361f1e8b2e23b3cbaadebce45ab399df8b76a1ee Feature #52: All users can now view and edit their description and university diff -r 361f1e8b2e23 -r d70a0b926135 app/controllers/my_controller.rb --- a/app/controllers/my_controller.rb Fri Dec 17 11:18:51 2010 +0000 +++ b/app/controllers/my_controller.rb Fri Dec 17 13:02:30 2010 +0000 @@ -52,11 +52,29 @@ def account @user = User.current @pref = @user.pref + @ssamr_user_details = @user.ssamr_user_detail if request.post? @user.attributes = params[:user] @user.mail_notification = params[:notification_option] || 'only_my_events' @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') + + if @user.ssamr_user_detail == nil + @ssamr_user_details = SsamrUserDetail.new() + @user.ssamr_user_detail = @ssamr_user_details + else + @ssamr_user_details = @user.ssamr_user_detail + end + + if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty? + @ssamr_user_details.description = @user.ssamr_user_detail.description + @ssamr_user_details.institution_id = @user.ssamr_user_detail.institution_id + else + @ssamr_user_details.description = params[:ssamr_user_details][:description] + @ssamr_user_details.institution_id = params[:ssamr_user_details][:institution_id] + @ssamr_user_details.save! + end + if @user.save @user.pref.save @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) diff -r 361f1e8b2e23 -r d70a0b926135 app/controllers/users_controller.rb --- a/app/controllers/users_controller.rb Fri Dec 17 11:18:51 2010 +0000 +++ b/app/controllers/users_controller.rb Fri Dec 17 13:02:30 2010 +0000 @@ -166,12 +166,13 @@ else @ssamr_user_details = @user.ssamr_user_detail end - - + if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty? @ssamr_user_details.description = @user.ssamr_user_detail.description + @ssamr_user_details.institution_id = @user.ssamr_user_detail.institution_id else @ssamr_user_details.description = params[:ssamr_user_details][:description] + @ssamr_user_details.institution_id = params[:ssamr_user_details][:institution_id] @ssamr_user_details.save! end diff -r 361f1e8b2e23 -r d70a0b926135 app/views/my/account.rhtml --- a/app/views/my/account.rhtml Fri Dec 17 11:18:51 2010 +0000 +++ b/app/views/my/account.rhtml Fri Dec 17 13:02:30 2010 +0000 @@ -9,6 +9,8 @@ :builder => TabularFormBuilder, :lang => current_language, :html => { :id => 'my_account_form' } do |f| %> + +
<%= custom_field_tag_with_label :user, value %>
<% end %> + <%= call_hook(:view_my_account, :user => @user, :form => f) %>+ <%= ssamr_user_detail.text_area :description, :rows => 3, :cols => 25, :required => true, :class => 'wiki-edit' %> +
++ + <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @user.ssamr_user_detail.institution_id.to_i} ) %> +
+ <% end %> +