summaryrefslogtreecommitdiff
path: root/app/controllers/projects_controller.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-10-19 09:32:07 +0000
committerDouwe Maan <douwe@gitlab.com>2015-10-19 09:32:07 +0000
commit8adeda37b55fc992e3cb15422cae5d9646640630 (patch)
tree527587a80e6b1dde56b4aca1f02f89998b97c8e3 /app/controllers/projects_controller.rb
parentc9edffcba6443d2bf72cfa6dda15fd53c106657b (diff)
parent6ad78d3ab1fc0ea9f344810e22b4fa7e8d67b6f7 (diff)
downloadgitlab-ce-8adeda37b55fc992e3cb15422cae5d9646640630.tar.gz
Merge branch 'hanloong/gitlab-ce-remove-forks-from-projects-settings' into 'master'
Add ability to remove the fork relationship from project settings ![Screen_Shot_2015-10-18_at_12.37.24](/uploads/676571642a4c90f7f286280d714599a3/Screen_Shot_2015-10-18_at_12.37.24.png) ![Screen_Shot_2015-10-18_at_12.37.28](/uploads/1a069ecfc4cd3b5438772a9c3f04b6fc/Screen_Shot_2015-10-18_at_12.37.28.png) Replaces !1579. Fixes #2578. See merge request !1636
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r--app/controllers/projects_controller.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index bb2df275b77..73200396ecc 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -8,7 +8,7 @@ class ProjectsController < ApplicationController
before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists?
# Authorize
- before_action :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive]
+ before_action :authorize_admin_project!, only: [:edit, :update]
before_action :event_filter, only: [:show, :activity]
layout :determine_layout
@@ -59,6 +59,8 @@ class ProjectsController < ApplicationController
end
def transfer
+ return access_denied! unless can?(current_user, :change_namespace, @project)
+
namespace = Namespace.find_by(id: params[:new_namespace_id])
::Projects::TransferService.new(project, current_user).execute(namespace)
@@ -67,6 +69,15 @@ class ProjectsController < ApplicationController
end
end
+ def remove_fork
+ return access_denied! unless can?(current_user, :remove_fork_project, @project)
+
+ if @project.forked?
+ @project.forked_project_link.destroy
+ flash[:notice] = 'The fork relationship has been removed.'
+ end
+ end
+
def activity
respond_to do |format|
format.html
@@ -142,6 +153,7 @@ class ProjectsController < ApplicationController
def archive
return access_denied! unless can?(current_user, :archive_project, @project)
+
@project.archive!
respond_to do |format|
@@ -151,6 +163,7 @@ class ProjectsController < ApplicationController
def unarchive
return access_denied! unless can?(current_user, :archive_project, @project)
+
@project.unarchive!
respond_to do |format|