Parcourir la source

Refactor: move method to model

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4224 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/1.1.0
Eric Davis il y a 13 ans
Parent
révision
747b9ec568
3 fichiers modifiés avec 13 ajouts et 23 suppressions
  1. 1
    7
      app/controllers/my_controller.rb
  2. 1
    16
      app/controllers/users_controller.rb
  3. 11
    0
      app/models/user.rb

+ 1
- 7
app/controllers/my_controller.rb Voir le fichier

return return
end end
end end
@notification_options = User::MAIL_NOTIFICATION_OPTIONS
# Only users that belong to more than 1 project can select projects for which they are notified
# Note that @user.membership.size would fail since AR ignores
# :include association option when doing a count
if @user.memberships.length < 1
@notification_options.delete_if {|option| option.first == :selected}
end
@notification_options = @user.valid_notification_options
@notification_option = @user.mail_notification #? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected') @notification_option = @user.mail_notification #? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')
end end



+ 1
- 16
app/controllers/users_controller.rb Voir le fichier



@user = User.new(:language => Setting.default_language) @user = User.new(:language => Setting.default_language)
@auth_sources = AuthSource.find(:all) @auth_sources = AuthSource.find(:all)

# TODO: Similar to My#account
# Only users that belong to more than 1 project can select projects for which they are notified
# Note that @user.membership.size would fail since AR ignores
# :include association option when doing a count
if @user.memberships.length < 1
@notification_options.delete_if {|option| option.first == :selected}
end
end end
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }


def edit def edit
@user = User.find(params[:id]) @user = User.find(params[:id])
# TODO: Similar to My#account
@notification_options = User::MAIL_NOTIFICATION_OPTIONS
# Only users that belong to more than 1 project can select projects for which they are notified
# Note that @user.membership.size would fail since AR ignores
# :include association option when doing a count
if @user.memberships.length < 1
@notification_options.delete_if {|option| option.first == :selected}
end
@notification_options = @user.valid_notification_options
@notification_option = @user.mail_notification @notification_option = @user.mail_notification


if request.post? if request.post?

+ 11
- 0
app/models/user.rb Voir le fichier

notified_projects_ids notified_projects_ids
end end


# Only users that belong to more than 1 project can select projects for which they are notified
def valid_notification_options
# Note that @user.membership.size would fail since AR ignores
# :include association option when doing a count
if memberships.length < 1
MAIL_NOTIFICATION_OPTIONS.delete_if {|option| option.first == :selected}
else
MAIL_NOTIFICATION_OPTIONS
end
end

# Find a user account by matching the exact login and then a case-insensitive # Find a user account by matching the exact login and then a case-insensitive
# version. Exact matches will be given priority. # version. Exact matches will be given priority.
def self.find_by_login(login) def self.find_by_login(login)

Chargement…
Annuler
Enregistrer