From 96d49bf04ce77c975fe500f4d961e4a1ffed4c26 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 30 Dec 2012 14:43:00 +0200 Subject: Use sdoc to generate application code documentation --- doc/code/classes/UsersProject.html | 871 +++++++++++++++++++++++++++++++++++++ 1 file changed, 871 insertions(+) create mode 100644 doc/code/classes/UsersProject.html (limited to 'doc/code/classes/UsersProject.html') diff --git a/doc/code/classes/UsersProject.html b/doc/code/classes/UsersProject.html new file mode 100644 index 00000000000..76ae5125a1d --- /dev/null +++ b/doc/code/classes/UsersProject.html @@ -0,0 +1,871 @@ + + + + + UsersProject + + + + + + + + + + + + + +
+
+ +
+ +

Schema Information

+ +

Table name: users_projects

+ +
id             :integer          not null, primary key
+user_id        :integer          not null
+project_id     :integer          not null
+created_at     :datetime         not null
+updated_at     :datetime         not null
+project_access :integer          default(0), not null
+ +
+ + + + + + + + + + + + + + + +
Methods
+
+ +
A
+
+ +
+ +
B
+
+ +
+ +
I
+
+ +
+ +
P
+
+ +
+ +
R
+
+ +
+ +
S
+
+ +
+ +
T
+
+ +
+ +
U
+
+ +
+ +
+ + + + +
Included Modules
+ + + + + + + + + + + + + +
Constants
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GUEST=10
 
REPORTER=20
 
DEVELOPER=30
 
MASTER=40
 
+ + + + + +
Attributes
+ + + + + + + + +
+ [RW] + skip_git
+ + + + + +
Class Public methods
+ +
+
+ + access_roles() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 140
+def access_roles
+  {
+    "Guest"     => GUEST,
+    "Reporter"  => REPORTER,
+    "Developer" => DEVELOPER,
+    "Master"    => MASTER
+  }
+end
+
+
+ +
+ +
+
+ + add_users_into_projects(project_ids, user_ids, project_access) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 41
+def add_users_into_projects(project_ids, user_ids, project_access)
+  UsersProject.transaction do
+    project_ids.each do |project_id|
+      user_ids.each do |user_id|
+        users_project = UsersProject.new(project_access: project_access, user_id: user_id)
+        users_project.project_id = project_id
+        users_project.skip_git = true
+        users_project.save
+      end
+    end
+    Gitlab::Gitolite.new.update_repositories(Project.where(id: project_ids))
+  end
+
+  true
+rescue
+  false
+end
+
+
+ +
+ +
+
+ + bulk_delete(project, user_ids) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 108
+def bulk_delete(project, user_ids)
+  UsersProject.transaction do
+    UsersProject.where(user_id: user_ids, project_id: project.id).each do |users_project|
+      users_project.skip_git = true
+      users_project.destroy
+    end
+
+    project.update_repository
+  end
+end
+
+
+ +
+ +
+
+ + bulk_import(project, user_ids, project_access) + + +
+ + +
+

TODO: depreceate in future in favor of ::add_users_into_projects

+
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 131
+def bulk_import(project, user_ids, project_access)
+  add_users_into_projects([project.id], user_ids, project_access)
+end
+
+
+ +
+ +
+
+ + bulk_update(project, user_ids, project_access) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 119
+def bulk_update(project, user_ids, project_access)
+  UsersProject.transaction do
+    UsersProject.where(user_id: user_ids, project_id: project.id).each do |users_project|
+      users_project.project_access = project_access
+      users_project.skip_git = true
+      users_project.save
+    end
+    project.update_repository
+  end
+end
+
+
+ +
+ +
+
+ + import_team(source_project, target_project) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 78
+def import_team(source_project, target_project)
+  source_team = source_project.users_projects.all
+  target_team = target_project.users_projects.all
+  target_user_ids = target_team.map(&:user_id)
+
+  source_team.reject! do |tm|
+    # Skip if user already present in team
+    target_user_ids.include?(tm.user_id)
+  end
+
+  source_team.map! do |tm|
+    new_tm = tm.dup
+    new_tm.id = nil
+    new_tm.project_id = target_project.id
+    new_tm.skip_git = true
+    new_tm
+  end
+
+  UsersProject.transaction do
+    source_team.each do |tm|
+      tm.save
+    end
+    target_project.update_repository
+  end
+
+  true
+rescue
+  false
+end
+
+
+ +
+ +
+
+ + truncate_team(project) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 74
+def truncate_team project
+  truncate_teams [project.id]
+end
+
+
+ +
+ +
+
+ + truncate_teams(project_ids) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 59
+def truncate_teams(project_ids)
+  UsersProject.transaction do
+    users_projects = UsersProject.where(project_id: project_ids)
+    users_projects.each do |users_project|
+      users_project.skip_git = true
+      users_project.destroy
+    end
+    Gitlab::Gitolite.new.update_repositories(Project.where(id: project_ids))
+  end
+
+  true
+rescue
+  false
+end
+
+
+ +
+ +
+
+ + user_bulk_import(user, project_ids, project_access) + + +
+ + +
+

TODO: depreceate in future in favor of ::add_users_into_projects

+
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 136
+def user_bulk_import(user, project_ids, project_access)
+  add_users_into_projects(project_ids, [user.id], project_access)
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + project_access_human() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 158
+def project_access_human
+  Project.access_options.key(self.project_access)
+end
+
+
+ +
+ +
+
+ + repo_access_human() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 162
+def repo_access_human
+  self.class.access_roles.invert[self.project_access]
+end
+
+
+ +
+ +
+
+ + role_access() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 150
+def role_access
+  project_access
+end
+
+
+ +
+ +
+
+ + skip_git?() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 166
+def skip_git?
+  !!@skip_git
+end
+
+
+ +
+ +
+
+ + update_repository() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/users_project.rb, line 154
+def update_repository
+  git_host.update_repository(project)
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file -- cgit v1.2.1