active and registered users can be selected as project members

pull/41/head
Jens Ulferts 14 years ago committed by Romano Licker
parent 8046e8e15c
commit 76568cc999
  1. 1
      app/controllers/projects_controller.rb
  2. 4
      app/models/principal.rb
  3. 7
      app/views/projects/settings/_members.rhtml

@ -253,7 +253,6 @@ private
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@issue_category ||= IssueCategory.new
@member ||= @project.members.new
@available_principles = Principal.possible_members("", 100) - @project.principals
@trackers = Tracker.all
@repository ||= @project.repository
@wiki ||= @project.wiki

@ -22,6 +22,8 @@ class Principal < ActiveRecord::Base
# Groups and active users
named_scope :active, :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status = 1)"
named_scope :active_or_registered, :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND (#{Principal.table_name}.status = #{User::STATUS_ACTIVE} OR #{Principal.table_name}.status = #{User::STATUS_REGISTERED}))"
named_scope :like, lambda {|q|
s = "%#{q.to_s.strip.downcase}%"
{:conditions => ["LOWER(login) LIKE :s OR LOWER(firstname) LIKE :s OR LOWER(lastname) LIKE :s OR LOWER(mail) LIKE :s", {:s => s}],
@ -36,7 +38,7 @@ class Principal < ActiveRecord::Base
end
def self.possible_members(criteria, limit)
Principal.active.like(criteria).find(:all, :limit => limit)
Principal.active_or_registered.like(criteria).find(:all, :limit => limit)
end
def <=>(principal)

@ -1,6 +1,7 @@
<%= error_messages_for 'member' %>
<% roles = Role.find_all_givable
members = @project.member_principals.find(:all, :include => [:roles, :principal]).sort %>
members = @project.member_principals.find(:all, :include => [:roles, :principal]).sort
available_principles = Principal.possible_members("", 100) - @project.principals %>
<div class="splitcontentleft">
<% if members.any? %>
@ -51,7 +52,7 @@
</div>
<div class="splitcontentright">
<% if roles.any? && @available_principles.any? %>
<% if roles.any? && available_principles.any? %>
<% remote_form_for(:member, @member, :url => {:controller => 'members', :action => 'new', :id => @project}, :method => :post,
:loading => '$(\'member-add-submit\').disable();',
:complete => 'if($(\'member-add-submit\')) $(\'member-add-submit\').enable();') do |f| %>
@ -66,7 +67,7 @@
%>
<div id="principals">
<%= principals_check_box_tags 'member[user_ids][]', @available_principles %>
<%= principals_check_box_tags 'member[user_ids][]', available_principles %>
</div>
<p><%= l(:label_role_plural) %>:

Loading…
Cancel
Save