group.rb 865 字节
Newer Older
D
Dmitriy Zaporozhets 已提交
1 2
# == Schema Information
#
D
Dmitriy Zaporozhets 已提交
3
# Table name: namespaces
D
Dmitriy Zaporozhets 已提交
4
#
A
Andrew8xx8 已提交
5 6 7 8 9 10 11
#  id          :integer          not null, primary key
#  name        :string(255)      not null
#  path        :string(255)      not null
#  owner_id    :integer          not null
#  created_at  :datetime         not null
#  updated_at  :datetime         not null
#  type        :string(255)
D
Dmitriy Zaporozhets 已提交
12
#  description :string(255)      default(""), not null
D
Dmitriy Zaporozhets 已提交
13 14
#

15
class Group < Namespace
A
Andrey Kumanyaev 已提交
16

17
  def add_users_to_project_teams(user_ids, project_access)
18 19 20 21 22
    UsersProject.add_users_into_projects(
      projects.map(&:id),
      user_ids,
      project_access
    )
23 24
  end

D
Dmitriy Zaporozhets 已提交
25
  def users
26 27 28
    users = User.joins(:users_projects).where(users_projects: {project_id: project_ids})
    users = users << owner
    users.uniq
D
Dmitriy Zaporozhets 已提交
29
  end
30 31 32 33

  def human_name
    name
  end
34 35 36 37

  def truncate_teams
    UsersProject.truncate_teams(project_ids)
  end
38
end