Mercurial > hg > soundsoftware-site
comparison app/controllers/users_controller.rb @ 84:432bb11e0390 cannam
Merge from branch "luisf"
author | Chris Cannam |
---|---|
date | Thu, 16 Dec 2010 10:03:20 +0000 |
parents | b5bd39e27658 |
children | e408a3f7089f |
comparison
equal
deleted
inserted
replaced
76:8a49eabbb30a | 84:432bb11e0390 |
---|---|
50 end | 50 end |
51 | 51 |
52 def show | 52 def show |
53 @user = User.find(params[:id]) | 53 @user = User.find(params[:id]) |
54 | 54 |
55 @description = @user.ssamr_user_detail.description | |
56 | |
55 # show projects based on current user visibility | 57 # show projects based on current user visibility |
56 @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current)) | 58 @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current)) |
57 | 59 |
58 events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10) | 60 events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10) |
59 @events_by_day = events.group_by(&:event_date) | 61 @events_by_day = events.group_by(&:event_date) |
68 | 70 |
69 rescue ActiveRecord::RecordNotFound | 71 rescue ActiveRecord::RecordNotFound |
70 render_404 | 72 render_404 |
71 end | 73 end |
72 | 74 |
73 def new | 75 def new |
74 @notification_options = User::MAIL_NOTIFICATION_OPTIONS | 76 @notification_options = User::MAIL_NOTIFICATION_OPTIONS |
75 @notification_option = Setting.default_notification_option | 77 @notification_option = Setting.default_notification_option |
76 | 78 |
77 @user = User.new(:language => Setting.default_language) | 79 @user = User.new(:language => Setting.default_language) |
78 @auth_sources = AuthSource.find(:all) | 80 @auth_sources = AuthSource.find(:all) |
81 | |
82 @ssamr_user_details = SsamrUserDetail.new | |
83 | |
79 end | 84 end |
80 | 85 |
81 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 } |
82 def create | 87 def create |
83 @notification_options = User::MAIL_NOTIFICATION_OPTIONS | 88 @notification_options = User::MAIL_NOTIFICATION_OPTIONS |
84 @notification_option = Setting.default_notification_option | 89 @notification_option = Setting.default_notification_option |
85 | 90 |
86 @user = User.new(params[:user]) | 91 @user = User.new(params[:user]) |
87 @user.admin = params[:user][:admin] || false | 92 @user.admin = params[:user][:admin] || false |
88 @user.login = params[:user][:login] | 93 @user.login = params[:user][:login] |
89 @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id | 94 @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id |
90 | 95 |
91 # TODO: Similar to My#account | 96 # TODO: Similar to My#account |
92 @user.mail_notification = params[:notification_option] || 'only_my_events' | 97 @user.mail_notification = params[:notification_option] || 'only_my_events' |
93 @user.pref.attributes = params[:pref] | 98 @user.pref.attributes = params[:pref] |
94 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') | 99 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') |
95 | 100 |
101 @ssamr_user_details = SsamrUserDetail.new(params[:ssamr_user_details]) | |
102 | |
103 # associates the 2 objects | |
104 @user.ssamr_user_detail = @ssamr_user_details | |
105 | |
96 if @user.save | 106 if @user.save |
97 @user.pref.save | 107 @user.pref.save |
108 | |
109 @ssamr_user_details.save! | |
110 | |
98 @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] : []) |
99 | 112 |
100 Mailer.deliver_account_information(@user, params[:password]) if params[:send_information] | 113 Mailer.deliver_account_information(@user, params[:password]) if params[:send_information] |
101 flash[:notice] = l(:notice_successful_create) | 114 flash[:notice] = l(:notice_successful_create) |
102 redirect_to(params[:continue] ? {:controller => 'users', :action => 'new'} : | 115 redirect_to(params[:continue] ? {:controller => 'users', :action => 'new'} : |
112 | 125 |
113 def edit | 126 def edit |
114 @user = User.find(params[:id]) | 127 @user = User.find(params[:id]) |
115 @notification_options = @user.valid_notification_options | 128 @notification_options = @user.valid_notification_options |
116 @notification_option = @user.mail_notification | 129 @notification_option = @user.mail_notification |
117 | 130 |
131 @ssamr_user_details = @user.ssamr_user_detail | |
132 | |
118 @auth_sources = AuthSource.find(:all) | 133 @auth_sources = AuthSource.find(:all) |
119 @membership ||= Member.new | 134 @membership ||= Member.new |
120 end | 135 end |
121 | 136 |
122 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } | 137 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } |
123 def update | 138 def update |
124 @user = User.find(params[:id]) | 139 @user = User.find(params[:id]) |
140 | |
125 @notification_options = @user.valid_notification_options | 141 @notification_options = @user.valid_notification_options |
126 @notification_option = @user.mail_notification | 142 @notification_option = @user.mail_notification |
127 | 143 |
128 @user.admin = params[:user][:admin] if params[:user][:admin] | 144 @user.admin = params[:user][:admin] if params[:user][:admin] |
129 @user.login = params[:user][:login] if params[:user][:login] | 145 @user.login = params[:user][:login] if params[:user][:login] |
136 was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE]) | 152 was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE]) |
137 # TODO: Similar to My#account | 153 # TODO: Similar to My#account |
138 @user.mail_notification = params[:notification_option] || 'only_my_events' | 154 @user.mail_notification = params[:notification_option] || 'only_my_events' |
139 @user.pref.attributes = params[:pref] | 155 @user.pref.attributes = params[:pref] |
140 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') | 156 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') |
157 | |
158 @ssamr_user_details = @user.ssamr_user_detail | |
159 if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty? | |
160 @ssamr_user_details.description = @user.ssamr_user_detail.description | |
161 else | |
162 @ssamr_user_details.description = params[:ssamr_user_details][:description] | |
163 @ssamr_user_details.save! | |
164 end | |
141 | 165 |
142 if @user.save | 166 if @user.save |
143 @user.pref.save | 167 @user.pref.save |
144 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) | 168 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) |
145 | 169 |