comparison app/controllers/users_controller.rb @ 61:aedfe093ec32 luisf

Now correctly creates a new user with the description
author luisf
date Thu, 02 Dec 2010 19:27:04 +0000
parents cf39b52d24b4
children b5bd39e27658
comparison
equal deleted inserted replaced
60:cf39b52d24b4 61:aedfe093ec32
70 70
71 rescue ActiveRecord::RecordNotFound 71 rescue ActiveRecord::RecordNotFound
72 render_404 72 render_404
73 end 73 end
74 74
75 def new 75 def new
76 @notification_options = User::MAIL_NOTIFICATION_OPTIONS 76 @notification_options = User::MAIL_NOTIFICATION_OPTIONS
77 @notification_option = Setting.default_notification_option 77 @notification_option = Setting.default_notification_option
78 78
79 @user = User.new(:language => Setting.default_language) 79 @user = User.new(:language => Setting.default_language)
80 @auth_sources = AuthSource.find(:all) 80 @auth_sources = AuthSource.find(:all)
81 81
82 @ssamr_user_details = SsamrUserDetail.new 82 @ssamr_user_details = SsamrUserDetail.new
83 83
84 end 84 end
85 85
86 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } 86 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
87 def create 87 def create
88 @notification_options = User::MAIL_NOTIFICATION_OPTIONS 88 @notification_options = User::MAIL_NOTIFICATION_OPTIONS
96 # TODO: Similar to My#account 96 # TODO: Similar to My#account
97 @user.mail_notification = params[:notification_option] || 'only_my_events' 97 @user.mail_notification = params[:notification_option] || 'only_my_events'
98 @user.pref.attributes = params[:pref] 98 @user.pref.attributes = params[:pref]
99 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') 99 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
100 100
101 @ssamr_user_details = @user.ssamr_user_detail 101 @ssamr_user_details = SsamrUserDetail.new(params[:ssamr_user_details])
102 @ssamr_user_details.description = params[:ssamr_user_details][:description] 102
103 103 # associates the 2 objects
104 @user.ssamr_user_detail = @ssamr_user_details
105
104 if @user.save 106 if @user.save
105 @user.pref.save 107 @user.pref.save
106 108
107 @ssamr_user_details.save! 109 @ssamr_user_details.save!
108 110
109 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) 111 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
110 112
111 Mailer.deliver_account_information(@user, params[:password]) if params[:send_information] 113 Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
156 @ssamr_user_details = @user.ssamr_user_detail 158 @ssamr_user_details = @user.ssamr_user_detail
157 @ssamr_user_details.description = params[:ssamr_user_details][:description] 159 @ssamr_user_details.description = params[:ssamr_user_details][:description]
158 160
159 @ssamr_user_details.save! 161 @ssamr_user_details.save!
160 162
161
162 if @user.save 163 if @user.save
163 @user.pref.save 164 @user.pref.save
164 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) 165 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
165 166
166 if was_activatedd 167 if was_activated
167 Mailer.deliver_account_activated(@user) 168 Mailer.deliver_account_activated(@user)
168 elsif @user.active? && params[:send_information] && !params[:password].blank? && @user.auth_source_id.nil? 169 elsif @user.active? && params[:send_information] && !params[:password].blank? && @user.auth_source_id.nil?
169 Mailer.deliver_account_information(@user, params[:password]) 170 Mailer.deliver_account_information(@user, params[:password])
170 end 171 end
171 flash[:notice] = l(:notice_successful_update) 172 flash[:notice] = l(:notice_successful_update)