diff app/controllers/users_controller.rb @ 60:cf39b52d24b4 luisf

DEVELOPMENT COMMIT: The description can now be seen and edited BUT when a new user registers the informations is not saved to the correct table.
author luisf
date Wed, 01 Dec 2010 18:04:19 +0000
parents e77d73b181e3
children aedfe093ec32
line wrap: on
line diff
--- a/app/controllers/users_controller.rb	Wed Dec 01 00:21:03 2010 +0000
+++ b/app/controllers/users_controller.rb	Wed Dec 01 18:04:19 2010 +0000
@@ -53,9 +53,7 @@
     @user = User.find(params[:id])
     
     @description = @user.ssamr_user_detail.description
-    
-    #  @description = @user.ssamr_user_detail.description
-        
+            
     # show projects based on current user visibility
     @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current))
     
@@ -74,12 +72,15 @@
     render_404
   end
 
-  def new
+  def new    
     @notification_options = User::MAIL_NOTIFICATION_OPTIONS
     @notification_option = Setting.default_notification_option
 
     @user = User.new(:language => Setting.default_language)
     @auth_sources = AuthSource.find(:all)
+
+    @ssamr_user_details = SsamrUserDetail.new
+
   end
   
   verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
@@ -87,22 +88,24 @@
     @notification_options = User::MAIL_NOTIFICATION_OPTIONS
     @notification_option = Setting.default_notification_option
 
-    @user = User.new(params[:user])
+    @user = User.new(params[:user])    
     @user.admin = params[:user][:admin] || false
     @user.login = params[:user][:login]
     @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id
 
-    @user.ssamr_user_detail.description = params[:user.ssamr_user_detail][:description]
-    
-    @ssamr_description = params[:user.ssamr_user_detail][:description]
-
     # TODO: Similar to My#account
     @user.mail_notification = params[:notification_option] || 'only_my_events'
     @user.pref.attributes = params[:pref]
     @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
 
+    @ssamr_user_details = @user.ssamr_user_detail
+    @ssamr_user_details.description = params[:ssamr_user_details][:description]
+    
     if @user.save
       @user.pref.save
+      
+      @ssamr_user_details.save!
+          
       @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
 
       Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
@@ -123,8 +126,8 @@
     @notification_options = @user.valid_notification_options
     @notification_option = @user.mail_notification
     
-#    @ssamr_description = @user.ssamr_user_detail
-
+    @ssamr_user_details = @user.ssamr_user_detail
+    
     @auth_sources = AuthSource.find(:all)
     @membership ||= Member.new
   end
@@ -132,7 +135,7 @@
   verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
   def update
     @user = User.find(params[:id])
-        
+
     @notification_options = @user.valid_notification_options
     @notification_option = @user.mail_notification
 
@@ -150,11 +153,17 @@
     @user.pref.attributes = params[:pref]
     @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
 
+    @ssamr_user_details = @user.ssamr_user_detail
+    @ssamr_user_details.description = params[:ssamr_user_details][:description]
+    
+    @ssamr_user_details.save!
+    
+
     if @user.save
       @user.pref.save
       @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
 
-      if was_activated
+      if was_activatedd
         Mailer.deliver_account_activated(@user)
       elsif @user.active? && params[:send_information] && !params[:password].blank? && @user.auth_source_id.nil?
         Mailer.deliver_account_information(@user, params[:password])