patch_for_locked_users_query.diff

Ksenia Altbregen, 2013-09-09 14:59

Download (3 KB)

View differences:

app/models/principal.rb (working copy)
60 60
      active.uniq.joins(:members).where("#{Member.table_name}.project_id IN (?)", ids)
61 61
    end
62 62
  }
63
  # Principals that are locked members of a collection of projects
64
  scope :locked_member_of, lambda {|projects|
65
    projects = [projects] unless project.is_a?(Array)
66
    if projects.empty?
67
      where("1=0")
68
    else
69
      ids = projects.map(&:id)
70
      locked.uniq.joins(:members).where("#{Member.table_name}.project_id IN (?)", ids)
71
    end
72
  }
63 73
  # Principals that are not members of projects
64 74
  scope :not_member_of, lambda {|projects|
65 75
    projects = [projects] unless projects.is_a?(Array)
app/models/issue_query.rb (working copy)
70 70
    issue_custom_fields = []
71 71
    
72 72
    if project
73
      principals += project.principals.sort
73
      principals += project.principals
74
      principals += project.locked_principals
75
      principals.sort
74 76
      unless project.leaf?
75 77
        subprojects = project.descendants.visible.all
76 78
        principals += Principal.member_of(subprojects)
79
        principals += Principal.locked_member_of(subprojects)
77 80
      end
78 81
      versions = project.shared_versions.all
79 82
      categories = project.issue_categories.all
......
82 85
    else
83 86
      if all_projects.any?
84 87
        principals += Principal.member_of(all_projects)
88
        principals += Principal.locked_member_of(all_projects)
85 89
      end
86 90
      versions = Version.visible.find_all_by_sharing('system')
87 91
      issue_custom_fields = IssueCustomField.where(:is_filter => true, :is_for_all => true).all
app/models/project.rb (working copy)
33 33
  has_many :member_principals, :class_name => 'Member',
34 34
                               :include => :principal,
35 35
                               :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
36
  has_many :locked_member_principals, :class_name => 'Member',
37
                                      :include => :principal,
38
                                      :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_LOCKED})"
36 39
  has_many :users, :through => :members
37 40
  has_many :principals, :through => :member_principals, :source => :principal
41
  has_many :locked_principals, :through => :locked_member_principals, :source => :principal
38 42

  
39 43
  has_many :enabled_modules, :dependent => :delete_all
40 44
  has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"