From: Jean-Philippe Lang Date: Sun, 12 Dec 2010 14:25:23 +0000 (+0000) Subject: Code cleanup. X-Git-Tag: 1.1.0~99 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2066b2f6665156670c7dcbff944cc3c5a827075d;p=redmine.git Code cleanup. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4497 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 26641b527..b381fbc8a 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -19,6 +19,7 @@ class MyController < ApplicationController before_filter :require_login helper :issues + helper :users helper :custom_fields BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues, @@ -65,7 +66,6 @@ class MyController < ApplicationController return end end - @notification_options = @user.valid_notification_options end # Manage user's password diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 15ba71830..85749920b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -85,16 +85,12 @@ class UsersController < ApplicationController end def new - @notification_options = User::MAIL_NOTIFICATION_OPTIONS - @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option) @auth_sources = AuthSource.find(:all) end verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } def create - @notification_options = User::MAIL_NOTIFICATION_OPTIONS - @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option) @user.safe_attributes = params[:user] @user.admin = params[:user][:admin] || false @@ -135,7 +131,6 @@ class UsersController < ApplicationController def edit @user = User.find(params[:id]) - @notification_options = @user.valid_notification_options @auth_sources = AuthSource.find(:all) @membership ||= Member.new @@ -144,7 +139,6 @@ class UsersController < ApplicationController verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } def update @user = User.find(params[:id]) - @notification_options = @user.valid_notification_options @user.admin = params[:user][:admin] if params[:user][:admin] @user.login = params[:user][:login] if params[:user][:login] diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 37cecc05c..c0caffa4a 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -33,6 +33,10 @@ module UsersHelper options end + def user_mail_notification_options(user) + user.valid_notification_options.collect {|o| [l(o.last), o.first]} + end + def change_status_link(user) url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil} diff --git a/app/views/users/_mail_notifications.html.erb b/app/views/users/_mail_notifications.html.erb index 5a8216d2a..9c7368820 100644 --- a/app/views/users/_mail_notifications.html.erb +++ b/app/views/users/_mail_notifications.html.erb @@ -1,5 +1,5 @@

-<%= select_tag 'user[mail_notification]', options_for_select(@notification_options.collect {|o| [l(o.last), o.first]}, @user.mail_notification), +<%= select_tag 'user[mail_notification]', options_for_select(user_mail_notification_options(@user), @user.mail_notification), :onchange => 'if (this.value == "selected") {Element.show("notified-projects")} else {Element.hide("notified-projects")}' %>

<% content_tag 'div', :id => 'notified-projects', :style => (@user.mail_notification == 'selected' ? '' : 'display:none;') do %>