@@ -66,13 +66,7 class MyController < ApplicationController | |||||
66 | return |
|
66 | return | |
67 | end |
|
67 | end | |
68 | end |
|
68 | end | |
69 | @notification_options = User::MAIL_NOTIFICATION_OPTIONS |
|
69 | @notification_options = @user.valid_notification_options | |
70 | # Only users that belong to more than 1 project can select projects for which they are notified |
|
|||
71 | # Note that @user.membership.size would fail since AR ignores |
|
|||
72 | # :include association option when doing a count |
|
|||
73 | if @user.memberships.length < 1 |
|
|||
74 | @notification_options.delete_if {|option| option.first == :selected} |
|
|||
75 | end |
|
|||
76 | @notification_option = @user.mail_notification #? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected') |
|
70 | @notification_option = @user.mail_notification #? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected') | |
77 | end |
|
71 | end | |
78 |
|
72 |
@@ -77,14 +77,6 class UsersController < ApplicationController | |||||
77 |
|
77 | |||
78 | @user = User.new(:language => Setting.default_language) |
|
78 | @user = User.new(:language => Setting.default_language) | |
79 | @auth_sources = AuthSource.find(:all) |
|
79 | @auth_sources = AuthSource.find(:all) | |
80 |
|
||||
81 | # TODO: Similar to My#account |
|
|||
82 | # Only users that belong to more than 1 project can select projects for which they are notified |
|
|||
83 | # Note that @user.membership.size would fail since AR ignores |
|
|||
84 | # :include association option when doing a count |
|
|||
85 | if @user.memberships.length < 1 |
|
|||
86 | @notification_options.delete_if {|option| option.first == :selected} |
|
|||
87 | end |
|
|||
88 | end |
|
80 | end | |
89 |
|
81 | |||
90 | verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } |
|
82 | verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } | |
@@ -121,14 +113,7 class UsersController < ApplicationController | |||||
121 |
|
113 | |||
122 | def edit |
|
114 | def edit | |
123 | @user = User.find(params[:id]) |
|
115 | @user = User.find(params[:id]) | |
124 | # TODO: Similar to My#account |
|
116 | @notification_options = @user.valid_notification_options | |
125 | @notification_options = User::MAIL_NOTIFICATION_OPTIONS |
|
|||
126 | # Only users that belong to more than 1 project can select projects for which they are notified |
|
|||
127 | # Note that @user.membership.size would fail since AR ignores |
|
|||
128 | # :include association option when doing a count |
|
|||
129 | if @user.memberships.length < 1 |
|
|||
130 | @notification_options.delete_if {|option| option.first == :selected} |
|
|||
131 | end |
|
|||
132 | @notification_option = @user.mail_notification |
|
117 | @notification_option = @user.mail_notification | |
133 |
|
118 | |||
134 | if request.post? |
|
119 | if request.post? |
@@ -259,6 +259,17 class User < Principal | |||||
259 | notified_projects_ids |
|
259 | notified_projects_ids | |
260 | end |
|
260 | end | |
261 |
|
261 | |||
|
262 | # Only users that belong to more than 1 project can select projects for which they are notified | |||
|
263 | def valid_notification_options | |||
|
264 | # Note that @user.membership.size would fail since AR ignores | |||
|
265 | # :include association option when doing a count | |||
|
266 | if memberships.length < 1 | |||
|
267 | MAIL_NOTIFICATION_OPTIONS.delete_if {|option| option.first == :selected} | |||
|
268 | else | |||
|
269 | MAIL_NOTIFICATION_OPTIONS | |||
|
270 | end | |||
|
271 | end | |||
|
272 | ||||
262 | # Find a user account by matching the exact login and then a case-insensitive |
|
273 | # Find a user account by matching the exact login and then a case-insensitive | |
263 | # version. Exact matches will be given priority. |
|
274 | # version. Exact matches will be given priority. | |
264 | def self.find_by_login(login) |
|
275 | def self.find_by_login(login) |
General Comments 0
You need to be logged in to leave comments.
Login now