Mercurial > hg > soundsoftware-site
comparison app/controllers/users_controller.rb @ 1116:bb32da3bea34 redmine-2.2-integration
Merge from live
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 14:41:20 +0000 |
parents | 433d4f72a19b 5e80956cc792 |
children | 96790506f247 |
comparison
equal
deleted
inserted
replaced
1115:433d4f72a19b | 1116:bb32da3bea34 |
---|---|
60 format.api | 60 format.api |
61 end | 61 end |
62 end | 62 end |
63 | 63 |
64 def show | 64 def show |
65 | |
66 if @user.ssamr_user_detail != nil | |
67 @description = @user.ssamr_user_detail.description | |
68 | |
69 if @user.ssamr_user_detail.institution_type != nil | |
70 # institution_type is true for listed institutions | |
71 if (@user.ssamr_user_detail.institution_type) | |
72 @institution_name = Institution.find(@user.ssamr_user_detail.institution_id).name | |
73 else | |
74 @institution_name = @user.ssamr_user_detail.other_institution | |
75 end | |
76 end | |
77 end | |
78 | |
65 # show projects based on current user visibility | 79 # show projects based on current user visibility |
66 @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current)) | 80 @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current)) |
67 | 81 |
68 events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10) | 82 events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10) |
69 @events_by_day = events.group_by(&:event_date) | 83 @events_by_day = events.group_by(&:event_date) |
79 format.html { render :layout => 'base' } | 93 format.html { render :layout => 'base' } |
80 format.api | 94 format.api |
81 end | 95 end |
82 end | 96 end |
83 | 97 |
84 def new | 98 def new |
85 @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option) | 99 @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option) |
86 @auth_sources = AuthSource.find(:all) | 100 @auth_sources = AuthSource.find(:all) |
101 | |
102 @ssamr_user_details = SsamrUserDetail.new | |
87 end | 103 end |
88 | 104 |
89 def create | 105 def create |
90 @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option) | 106 @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option) |
91 @user.safe_attributes = params[:user] | 107 @user.safe_attributes = params[:user] |
108 @user = User.new(params[:user]) | |
92 @user.admin = params[:user][:admin] || false | 109 @user.admin = params[:user][:admin] || false |
93 @user.login = params[:user][:login] | 110 @user.login = params[:user][:login] |
94 @user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation] unless @user.auth_source_id | 111 @user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation] unless @user.auth_source_id |
112 | |
113 # TODO: Similar to My#account | |
114 @user.pref.attributes = params[:pref] | |
115 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') | |
116 | |
117 @ssamr_user_details = SsamrUserDetail.new(params[:ssamr_user_details]) | |
118 | |
119 # associates the 2 objects | |
120 @user.ssamr_user_detail = @ssamr_user_details | |
95 | 121 |
96 if @user.save | 122 if @user.save |
97 @user.pref.attributes = params[:pref] | 123 @user.pref.attributes = params[:pref] |
98 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') | 124 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') |
99 @user.pref.save | 125 @user.pref.save |
100 @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) | 126 |
127 @ssamr_user_details.save! | |
128 | |
101 | 129 |
102 Mailer.account_information(@user, params[:user][:password]).deliver if params[:send_information] | 130 Mailer.account_information(@user, params[:user][:password]).deliver if params[:send_information] |
103 | 131 |
104 respond_to do |format| | 132 respond_to do |format| |
105 format.html { | 133 format.html { |
122 end | 150 end |
123 end | 151 end |
124 end | 152 end |
125 | 153 |
126 def edit | 154 def edit |
155 | |
156 @ssamr_user_details = @user.ssamr_user_detail | |
157 | |
158 if @user.ssamr_user_detail == nil | |
159 @selected_institution_id = nil | |
160 else | |
161 @selected_institution_id = @user.ssamr_user_detail.institution_id.to_i | |
162 end | |
163 | |
127 @auth_sources = AuthSource.find(:all) | 164 @auth_sources = AuthSource.find(:all) |
128 @membership ||= Member.new | 165 @membership ||= Member.new |
129 end | 166 end |
130 | 167 |
131 def update | 168 def update |
139 was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE]) | 176 was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE]) |
140 # TODO: Similar to My#account | 177 # TODO: Similar to My#account |
141 @user.pref.attributes = params[:pref] | 178 @user.pref.attributes = params[:pref] |
142 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') | 179 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') |
143 | 180 |
181 if @user.ssamr_user_detail == nil | |
182 @ssamr_user_details = SsamrUserDetail.new() | |
183 @user.ssamr_user_detail = @ssamr_user_details | |
184 else | |
185 @ssamr_user_details = @user.ssamr_user_detail | |
186 end | |
187 | |
188 if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty? | |
189 @ssamr_user_details.description = @user.ssamr_user_detail.description | |
190 @ssamr_user_details.institution_id = @user.ssamr_user_detail.institution_id | |
191 @ssamr_user_details.other_institution = @user.ssamr_user_detail.other_institution | |
192 @ssamr_user_details.institution_type = @user.ssamr_user_detail.institution_type | |
193 | |
194 else | |
195 @ssamr_user_details.description = params[:ssamr_user_details][:description] | |
196 @ssamr_user_details.institution_id = params[:ssamr_user_details][:institution_id] | |
197 @ssamr_user_details.other_institution = params[:ssamr_user_details][:other_institution] | |
198 @ssamr_user_details.institution_type = params[:ssamr_user_details][:institution_type] | |
199 end | |
200 | |
144 if @user.save | 201 if @user.save |
145 @user.pref.save | 202 @user.pref.save |
146 @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) | 203 @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) |
147 | 204 |
148 if was_activated | 205 if was_activated |