From 5f361e71df2d50d06b54370530f2d53bf928dfbf Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 26 Jan 2007 20:52:52 +0000 Subject: [PATCH] only active users are now proposed when adding a member to a project git-svn-id: http://redmine.rubyforge.org/svn/trunk@190 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 2 +- app/models/user.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 403f4a5f..41b9e5b3 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -92,7 +92,7 @@ class ProjectsController < ApplicationController @issue_category ||= IssueCategory.new @member ||= @project.members.new @roles = Role.find(:all) - @users = User.find(:all) - @project.members.find(:all, :include => :user).collect{|m| m.user } + @users = User.find_active(:all) - @project.users @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } end diff --git a/app/models/user.rb b/app/models/user.rb index 8a596168..bf2930a0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -49,7 +49,19 @@ class User < ActiveRecord::Base # update hashed_password if password was set self.hashed_password = User.hash_password(self.password) if self.password end - + + def self.active + with_scope :find => { :conditions => [ "status = ?", STATUS_ACTIVE ] } do + yield + end + end + + def self.find_active(*args) + active do + find(*args) + end + end + # Returns the user that matches provided login and password, or nil def self.try_to_login(login, password) user = find(:first, :conditions => ["login=?", login])