##// END OF EJS Templates
Refactor: move method to model...
Eric Davis -
r4110:747b9ec5683f
parent child
Show More
@@ -66,13 +66,7 class MyController < ApplicationController
66 66 return
67 67 end
68 68 end
69 @notification_options = User::MAIL_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
69 @notification_options = @user.valid_notification_options
76 70 @notification_option = @user.mail_notification #? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')
77 71 end
78 72
@@ -77,14 +77,6 class UsersController < ApplicationController
77 77
78 78 @user = User.new(:language => Setting.default_language)
79 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 80 end
89 81
90 82 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
@@ -121,14 +113,7 class UsersController < ApplicationController
121 113
122 114 def edit
123 115 @user = User.find(params[:id])
124 # TODO: Similar to My#account
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
116 @notification_options = @user.valid_notification_options
132 117 @notification_option = @user.mail_notification
133 118
134 119 if request.post?
@@ -259,6 +259,17 class User < Principal
259 259 notified_projects_ids
260 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 273 # Find a user account by matching the exact login and then a case-insensitive
263 274 # version. Exact matches will be given priority.
264 275 def self.find_by_login(login)
General Comments 0
You need to be logged in to leave comments. Login now