From 2066b2f6665156670c7dcbff944cc3c5a827075d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 12 Dec 2010 14:25:23 +0000 Subject: [PATCH] Code cleanup. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4497 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/my_controller.rb | 2 +- app/controllers/users_controller.rb | 6 ------ app/helpers/users_helper.rb | 4 ++++ app/views/users/_mail_notifications.html.erb | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 26641b52..b381fbc8 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 15ba7183..85749920 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 37cecc05..c0caffa4 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 5a8216d2..9c736882 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 %>