Commit c9370b753a55d946523da65b6a0c4bed061d68c8
Exists in
master
and in
4 other branches
Merge branch 'remove/root_namespace' of /home/git/repositories/gitlab/gitlabhq into 6-0-dev
Showing
16 changed files
with
21 additions
and
111 deletions
Show diff stats
app/contexts/projects/create_context.rb
... | ... | @@ -33,7 +33,7 @@ module Projects |
33 | 33 | # Find matching namespace and check if it allowed |
34 | 34 | # for current user if namespace_id passed. |
35 | 35 | if allowed_namespace?(current_user, namespace_id) |
36 | - @project.namespace_id = namespace_id unless namespace_id == Namespace.global_id | |
36 | + @project.namespace_id = namespace_id | |
37 | 37 | else |
38 | 38 | deny_namespace |
39 | 39 | return @project |
... | ... | @@ -75,12 +75,8 @@ module Projects |
75 | 75 | end |
76 | 76 | |
77 | 77 | def allowed_namespace?(user, namespace_id) |
78 | - if namespace_id == Namespace.global_id | |
79 | - return user.admin | |
80 | - else | |
81 | - namespace = Namespace.find_by_id(namespace_id) | |
82 | - current_user.can?(:manage_namespace, namespace) | |
83 | - end | |
78 | + namespace = Namespace.find_by_id(namespace_id) | |
79 | + current_user.can?(:manage_namespace, namespace) | |
84 | 80 | end |
85 | 81 | end |
86 | 82 | end | ... | ... |
app/contexts/projects/transfer_context.rb
... | ... | @@ -5,12 +5,7 @@ module Projects |
5 | 5 | allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin |
6 | 6 | |
7 | 7 | if allowed_transfer && namespace_id.present? |
8 | - if namespace_id == Namespace.global_id | |
9 | - if project.namespace.present? | |
10 | - # Transfer to global namespace from anyone | |
11 | - project.transfer(nil) | |
12 | - end | |
13 | - elsif namespace_id.to_i != project.namespace_id | |
8 | + if namespace_id.to_i != project.namespace_id | |
14 | 9 | # Transfer to someone namespace |
15 | 10 | namespace = Namespace.find(namespace_id) |
16 | 11 | project.transfer(namespace) | ... | ... |
app/controllers/admin/projects_controller.rb
... | ... | @@ -9,7 +9,6 @@ class Admin::ProjectsController < Admin::ApplicationController |
9 | 9 | @projects = @projects.where(public: true) if params[:public_only].present? |
10 | 10 | @projects = @projects.with_push if params[:with_push].present? |
11 | 11 | @projects = @projects.abandoned if params[:abandoned].present? |
12 | - @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id | |
13 | 12 | @projects = @projects.search(params[:name]) if params[:name].present? |
14 | 13 | @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) |
15 | 14 | end | ... | ... |
app/controllers/application_controller.rb
... | ... | @@ -95,14 +95,6 @@ class ApplicationController < ActionController::Base |
95 | 95 | return access_denied! unless can?(current_user, :create_team, nil) |
96 | 96 | end |
97 | 97 | |
98 | - def authorize_manage_user_team! | |
99 | - return access_denied! unless user_team.present? && can?(current_user, :manage_user_team, user_team) | |
100 | - end | |
101 | - | |
102 | - def authorize_admin_user_team! | |
103 | - return access_denied! unless user_team.present? && can?(current_user, :admin_user_team, user_team) | |
104 | - end | |
105 | - | |
106 | 98 | def access_denied! |
107 | 99 | render "errors/access_denied", layout: "errors", status: 404 |
108 | 100 | end | ... | ... |
app/helpers/admin/teams/members_helper.rb
app/helpers/admin/teams/projects_helper.rb
app/helpers/namespaces_helper.rb
... | ... | @@ -3,12 +3,10 @@ module NamespacesHelper |
3 | 3 | groups = current_user.owned_groups.select {|n| n.type == 'Group'} |
4 | 4 | users = current_user.namespaces.reject {|n| n.type == 'Group'} |
5 | 5 | |
6 | - global_opts = ["Global", [['/', Namespace.global_id]] ] | |
7 | 6 | group_opts = ["Groups", groups.sort_by(&:human_name).map {|g| [g.human_name, g.id]} ] |
8 | 7 | users_opts = [ "Users", users.sort_by(&:human_name).map {|u| [u.human_name, u.id]} ] |
9 | 8 | |
10 | 9 | options = [] |
11 | - options << global_opts if current_user.admin | |
12 | 10 | options << group_opts |
13 | 11 | options << users_opts |
14 | 12 | ... | ... |
app/models/concerns/issuable.rb
... | ... | @@ -21,7 +21,6 @@ module Issuable |
21 | 21 | scope :opened, -> { with_state(:opened) } |
22 | 22 | scope :closed, -> { with_state(:closed) } |
23 | 23 | scope :of_group, ->(group) { where(project_id: group.project_ids) } |
24 | - scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) } | |
25 | 24 | scope :assigned_to, ->(u) { where(assignee_id: u.id)} |
26 | 25 | scope :recent, -> { order("created_at DESC") } |
27 | 26 | scope :assigned, -> { where("assignee_id IS NOT NULL") } | ... | ... |
app/models/project.rb
... | ... | @@ -61,12 +61,6 @@ class Project < ActiveRecord::Base |
61 | 61 | has_many :snippets, dependent: :destroy, class_name: "ProjectSnippet" |
62 | 62 | has_many :hooks, dependent: :destroy, class_name: "ProjectHook" |
63 | 63 | has_many :protected_branches, dependent: :destroy |
64 | - has_many :user_team_project_relationships, dependent: :destroy | |
65 | - | |
66 | - has_many :users, through: :users_projects | |
67 | - has_many :user_teams, through: :user_team_project_relationships | |
68 | - has_many :user_team_user_relationships, through: :user_teams | |
69 | - has_many :user_teams_members, through: :user_team_user_relationships | |
70 | 64 | |
71 | 65 | has_many :deploy_keys_projects, dependent: :destroy |
72 | 66 | has_many :deploy_keys, through: :deploy_keys_projects | ... | ... |
app/views/dashboard/_teams.html.haml
... | ... | @@ -1,23 +0,0 @@ |
1 | -.ui-box.teams-box | |
2 | - %h5.title | |
3 | - Teams | |
4 | - %span.light | |
5 | - (#{teams.count}) | |
6 | - %span.pull-right | |
7 | - = link_to new_team_path, class: "btn btn-small" do | |
8 | - %i.icon-plus | |
9 | - New Team | |
10 | - %ul.well-list | |
11 | - - teams.each do |team| | |
12 | - %li | |
13 | - = link_to team_path(id: team.path), class: dom_class(team) do | |
14 | - %strong.well-title= truncate(team.name, length: 35) | |
15 | - %span.pull-right.light | |
16 | - - if team.owner == current_user | |
17 | - %i.icon-wrench | |
18 | - - tm = current_user.user_team_user_relationships.find_by_user_team_id(team.id) | |
19 | - - if tm | |
20 | - = tm.access_human | |
21 | - - if teams.blank? | |
22 | - %li | |
23 | - %h3.nothing_here_message You have no teams yet. |
app/views/layouts/nav/_team.html.haml
... | ... | @@ -1,25 +0,0 @@ |
1 | -%ul | |
2 | - = nav_link(path: 'teams#show', html_options: {class: 'home'}) do | |
3 | - = link_to team_path(@team), title: "Home" do | |
4 | - %i.icon-home | |
5 | - | |
6 | - = nav_link(path: 'teams#issues') do | |
7 | - = link_to issues_team_path(@team) do | |
8 | - Issues | |
9 | - %span.count= Issue.opened.of_user_team(@team).count | |
10 | - | |
11 | - = nav_link(path: 'teams#merge_requests') do | |
12 | - = link_to merge_requests_team_path(@team) do | |
13 | - Merge Requests | |
14 | - %span.count= MergeRequest.opened.of_user_team(@team).count | |
15 | - | |
16 | - = nav_link(controller: [:members]) do | |
17 | - = link_to team_members_path(@team), class: "team-tab tab" do | |
18 | - Members | |
19 | - %span.count= @team.members.count | |
20 | - | |
21 | - - if can? current_user, :manage_user_team, @team | |
22 | - = nav_link(path: 'teams#edit') do | |
23 | - = link_to edit_team_path(@team), class: "stat-tab tab " do | |
24 | - Settings | |
25 | - |
app/views/projects/edit.html.haml
... | ... | @@ -129,7 +129,7 @@ |
129 | 129 | %span Namespace |
130 | 130 | .controls |
131 | 131 | .clearfix |
132 | - = f.select :namespace_id, namespaces_options(@project.namespace_id || Namespace::global_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'} | |
132 | + = f.select :namespace_id, namespaces_options(@project.namespace_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'} | |
133 | 133 | %ul |
134 | 134 | %li Be careful. Changing project namespace can have unintended side effects |
135 | 135 | %li You can transfer project only to namespaces you can manage | ... | ... |
app/views/team_members/_assigned_team.html.haml
... | ... | @@ -1,10 +0,0 @@ |
1 | -%li{id: dom_id(team), class: "user_team_row team_#{team.id}"} | |
2 | - .pull-right | |
3 | - - if can?(current_user, :admin_team_member, @project) | |
4 | - = link_to resign_project_team_path(@project, team), method: :delete, confirm: "Are you sure?", class: "btn btn-remove btn-tiny" do | |
5 | - %i.icon-minus.icon-white | |
6 | - | |
7 | - %strong= link_to team.name, team_path(team), title: team.name, class: "dark" | |
8 | - %br | |
9 | - %small.cgray Members: #{team.members.count} | |
10 | - %small.cgray Max access: #{team_relation.human_max_access} |
app/views/team_members/_assigned_teams.html.haml
app/views/team_members/index.html.haml
... | ... | @@ -24,10 +24,3 @@ |
24 | 24 | |
25 | 25 | - else |
26 | 26 | = render "team_members/team", members: @users_projects |
27 | - | |
28 | -- if @assigned_teams.present? | |
29 | - %h5 | |
30 | - Assigned teams | |
31 | - (#{@project.user_teams.count}) | |
32 | - %div | |
33 | - = render "team_members/assigned_teams", assigned_teams: @assigned_teams | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | +desc "GITLAB | Migrate Global Projects to Namespaces" | |
2 | +task migrate_global_projects: :environment do | |
3 | + puts "This will move all projects without namespace to owner namespace" | |
4 | + ask_to_continue | |
5 | + | |
6 | + Project.where(namespace_id: nil).find_each(batch_size: 20) do |project| | |
7 | + begin | |
8 | + project.transfer(project.owner.namespace) | |
9 | + print '.' | |
10 | + rescue => ex | |
11 | + puts ex.message | |
12 | + print 'F' | |
13 | + end | |
14 | + end | |
15 | +end | |
16 | + | ... | ... |