summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/projects_controller.rb7
-rw-r--r--app/controllers/application_controller.rb6
-rw-r--r--app/controllers/projects/application_controller.rb8
-rw-r--r--app/controllers/projects/avatars_controller.rb2
-rw-r--r--app/controllers/projects/blob_controller.rb11
-rw-r--r--app/controllers/projects/branches_controller.rb8
-rw-r--r--app/controllers/projects/compare_controller.rb3
-rw-r--r--app/controllers/projects/deploy_keys_controller.rb9
-rw-r--r--app/controllers/projects/forks_controller.rb7
-rw-r--r--app/controllers/projects/hooks_controller.rb4
-rw-r--r--app/controllers/projects/imports_controller.rb10
-rw-r--r--app/controllers/projects/issues_controller.rb8
-rw-r--r--app/controllers/projects/labels_controller.rb16
-rw-r--r--app/controllers/projects/merge_requests_controller.rb11
-rw-r--r--app/controllers/projects/milestones_controller.rb5
-rw-r--r--app/controllers/projects/protected_branches_controller.rb5
-rw-r--r--app/controllers/projects/refs_controller.rb10
-rw-r--r--app/controllers/projects/repositories_controller.rb2
-rw-r--r--app/controllers/projects/services_controller.rb7
-rw-r--r--app/controllers/projects/snippets_controller.rb7
-rw-r--r--app/controllers/projects/tags_controller.rb4
-rw-r--r--app/controllers/projects/team_members_controller.rb13
-rw-r--r--app/controllers/projects/tree_controller.rb5
-rw-r--r--app/controllers/projects/wikis_controller.rb17
-rw-r--r--app/controllers/projects_controller.rb23
-rw-r--r--app/controllers/uploads_controller.rb9
26 files changed, 148 insertions, 69 deletions
diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb
index 7c2388e81be..2b1fc862b7f 100644
--- a/app/controllers/admin/projects_controller.rb
+++ b/app/controllers/admin/projects_controller.rb
@@ -25,13 +25,16 @@ class Admin::ProjectsController < Admin::ApplicationController
def transfer
::Projects::TransferService.new(@project, current_user, params.dup).execute
- redirect_to [:admin, @project.reload]
+ @project.reload
+ redirect_to admin_namespace_project_path(@project.namespace, @project)
end
protected
def project
- @project = Project.find_with_namespace(params[:id])
+ @project = Project.find_with_namespace(
+ [params[:namespace_id], '/', params[:id]].join('')
+ )
@project || render_404
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6553027b430..eb3be08df56 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -93,6 +93,7 @@ class ApplicationController < ActionController::Base
def project
unless @project
+ namespace = params[:namespace_id]
id = params[:project_id] || params[:id]
# Redirect from
@@ -104,7 +105,7 @@ class ApplicationController < ActionController::Base
redirect_to request.original_url.gsub(/\.git\Z/, '') and return
end
- @project = Project.find_with_namespace(id)
+ @project = Project.find_with_namespace("#{namespace}/#{id}")
if @project and can?(current_user, :read_project, @project)
@project
@@ -121,7 +122,8 @@ class ApplicationController < ActionController::Base
def repository
@repository ||= project.repository
- rescue Grit::NoSuchPathError
+ rescue Grit::NoSuchPathError(e)
+ log_exception(e)
nil
end
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index 7e4580017dd..4719933394f 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -8,7 +8,8 @@ class Projects::ApplicationController < ApplicationController
# for non-signed users
if !current_user
id = params[:project_id] || params[:id]
- @project = Project.find_with_namespace(id)
+ project_with_namespace = "#{params[:namespace_id]}/#{id}"
+ @project = Project.find_with_namespace(project_with_namespace)
return if @project && @project.public?
end
@@ -26,7 +27,10 @@ class Projects::ApplicationController < ApplicationController
def require_branch_head
unless @repository.branch_names.include?(@ref)
- redirect_to project_tree_path(@project, @ref), notice: "This action is not allowed unless you are on top of a branch"
+ redirect_to(
+ namespace_project_tree_path(@project.namespace, @project, @ref),
+ notice: "This action is not allowed unless you are on top of a branch"
+ )
end
end
end
diff --git a/app/controllers/projects/avatars_controller.rb b/app/controllers/projects/avatars_controller.rb
index a482b90880d..b90a95c3aab 100644
--- a/app/controllers/projects/avatars_controller.rb
+++ b/app/controllers/projects/avatars_controller.rb
@@ -24,6 +24,6 @@ class Projects::AvatarsController < Projects::ApplicationController
@project.save
@project.reset_events_cache
- redirect_to edit_project_path(@project)
+ redirect_to edit_namespace_project_path(@project.namespace, @project)
end
end
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 8071f13173d..1207548eae0 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -25,7 +25,7 @@ class Projects::BlobController < Projects::ApplicationController
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
- redirect_to project_blob_path(@project, File.join(@ref, file_path))
+ redirect_to namespace_project_blob_path(@project.namespace, @project, File.join(@ref, file_path))
else
flash[:alert] = result[:message]
render :new
@@ -70,7 +70,8 @@ class Projects::BlobController < Projects::ApplicationController
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
- redirect_to project_tree_path(@project, @ref)
+ redirect_to namespace_project_tree_path(@project.namespace, @project,
+ @ref)
else
flash[:alert] = result[:message]
render :show
@@ -102,7 +103,7 @@ class Projects::BlobController < Projects::ApplicationController
else
if tree = @repository.tree(@commit.id, @path)
if tree.entries.any?
- redirect_to project_tree_path(@project, File.join(@ref, @path)) and return
+ redirect_to namespace_project_tree_path(@project.namespace, @project, File.join(@ref, @path)) and return
end
end
@@ -128,10 +129,10 @@ class Projects::BlobController < Projects::ApplicationController
def after_edit_path
@after_edit_path ||=
if from_merge_request
- diffs_project_merge_request_path(from_merge_request.target_project, from_merge_request) +
+ diffs_namespace_project_merge_request_path(from_merge_request.target_project.namespace, from_merge_request.target_project, from_merge_request) +
"#file-path-#{hexdigest(@path)}"
else
- project_blob_path(@project, @id)
+ namespace_project_blob_path(@project.namespace, @project, @id)
end
end
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb
index f7bb36c40bb..690501f3060 100644
--- a/app/controllers/projects/branches_controller.rb
+++ b/app/controllers/projects/branches_controller.rb
@@ -23,7 +23,8 @@ class Projects::BranchesController < Projects::ApplicationController
if result[:status] == :success
@branch = result[:branch]
- redirect_to project_tree_path(@project, @branch.name)
+ redirect_to namespace_project_tree_path(@project.namespace, @project,
+ @branch.name)
else
@error = result[:message]
render action: 'new'
@@ -35,7 +36,10 @@ class Projects::BranchesController < Projects::ApplicationController
@branch_name = params[:id]
respond_to do |format|
- format.html { redirect_to project_branches_path(@project) }
+ format.html do
+ redirect_to namespace_project_branches_path(@project.namespace,
+ @project)
+ end
format.js
end
end
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb
index 8a359042d7b..146808fa562 100644
--- a/app/controllers/projects/compare_controller.rb
+++ b/app/controllers/projects/compare_controller.rb
@@ -25,6 +25,7 @@ class Projects::CompareController < Projects::ApplicationController
end
def create
- redirect_to project_compare_path(@project, params[:from], params[:to])
+ redirect_to namespace_project_compare_path(@project.namespace, @project,
+ params[:from], params[:to])
end
end
diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb
index 024b9520d30..b7cc305899c 100644
--- a/app/controllers/projects/deploy_keys_controller.rb
+++ b/app/controllers/projects/deploy_keys_controller.rb
@@ -25,7 +25,8 @@ class Projects::DeployKeysController < Projects::ApplicationController
@key = DeployKey.new(deploy_key_params)
if @key.valid? && @project.deploy_keys << @key
- redirect_to project_deploy_keys_path(@project)
+ redirect_to namespace_project_deploy_keys_path(@project.namespace,
+ @project)
else
render "new"
end
@@ -44,13 +45,15 @@ class Projects::DeployKeysController < Projects::ApplicationController
def enable
@project.deploy_keys << available_keys.find(params[:id])
- redirect_to project_deploy_keys_path(@project)
+ redirect_to namespace_project_deploy_keys_path(@project.namespace,
+ @project)
end
def disable
@project.deploy_keys_projects.where(deploy_key_id: params[:id]).last.destroy
- redirect_to project_deploy_keys_path(@project)
+ redirect_to namespace_project_deploy_keys_path(@project.namespace,
+ @project)
end
protected
diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb
index 414da0bbdc9..21a151a426e 100644
--- a/app/controllers/projects/forks_controller.rb
+++ b/app/controllers/projects/forks_controller.rb
@@ -9,11 +9,14 @@ class Projects::ForksController < Projects::ApplicationController
end
def create
- namespace = Namespace.find(params[:namespace_id])
+ namespace = Namespace.find(params[:namespace_key])
@forked_project = ::Projects::ForkService.new(project, current_user, namespace: namespace).execute
if @forked_project.saved? && @forked_project.forked?
- redirect_to(@forked_project, notice: 'Project was successfully forked.')
+ redirect_to(
+ namespace_project_path(@forked_project.namespace, @forked_project),
+ notice: 'Project was successfully forked.'
+ )
else
@title = 'Fork project'
render :error
diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb
index 2d6c3111192..ba95bb13e1f 100644
--- a/app/controllers/projects/hooks_controller.rb
+++ b/app/controllers/projects/hooks_controller.rb
@@ -16,7 +16,7 @@ class Projects::HooksController < Projects::ApplicationController
@hook.save
if @hook.valid?
- redirect_to project_hooks_path(@project)
+ redirect_to namespace_project_hooks_path(@project.namespace, @project)
else
@hooks = @project.hooks.select(&:persisted?)
render :index
@@ -43,7 +43,7 @@ class Projects::HooksController < Projects::ApplicationController
def destroy
hook.destroy
- redirect_to project_hooks_path(@project)
+ redirect_to namespace_project_hooks_path(@project.namespace, @project)
end
private
diff --git a/app/controllers/projects/imports_controller.rb b/app/controllers/projects/imports_controller.rb
index b8350642804..e2f957a640c 100644
--- a/app/controllers/projects/imports_controller.rb
+++ b/app/controllers/projects/imports_controller.rb
@@ -20,7 +20,7 @@ class Projects::ImportsController < Projects::ApplicationController
end
end
- redirect_to project_import_path(@project)
+ redirect_to namespace_project_import_path(@project.namespace, @project)
end
def show
@@ -28,7 +28,8 @@ class Projects::ImportsController < Projects::ApplicationController
if @project.import_finished?
redirect_to(@project) and return
else
- redirect_to new_project_import_path(@project) and return
+ redirect_to new_namespace_project_import_path(@project.namespace,
+ @project) && return
end
end
end
@@ -37,13 +38,14 @@ class Projects::ImportsController < Projects::ApplicationController
def require_no_repo
if @project.repository_exists?
- redirect_to(@project) and return
+ redirect_to(namespace_project_path(@project.namespace, @project)) and return
end
end
def redirect_if_progress
if @project.import_in_progress?
- redirect_to project_import_path(@project) and return
+ redirect_to namespace_project_import_path(@project.namespace, @project) &&
+ return
end
end
end
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index 42e207cf376..73b58285c61 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -60,7 +60,8 @@ class Projects::IssuesController < Projects::ApplicationController
respond_to do |format|
format.html do
if @issue.valid?
- redirect_to project_issue_path(@project, @issue)
+ redirect_to namespace_project_issue_path(@project.namespace,
+ @project, @issue)
else
render :new
end
@@ -78,7 +79,7 @@ class Projects::IssuesController < Projects::ApplicationController
format.js
format.html do
if @issue.valid?
- redirect_to [@project, @issue]
+ redirect_to [@project.namespace.becomes(Namespace), @project, @issue]
else
render :edit
end
@@ -128,7 +129,8 @@ class Projects::IssuesController < Projects::ApplicationController
issue = @project.issues.find_by(id: params[:id])
if issue
- redirect_to project_issue_path(@project, issue)
+ redirect_to namespace_project_issue_path(@project.namespace, @project,
+ issue)
return
else
raise ActiveRecord::RecordNotFound.new
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb
index b61fef3b627..5e31fce4b0e 100644
--- a/app/controllers/projects/labels_controller.rb
+++ b/app/controllers/projects/labels_controller.rb
@@ -18,7 +18,7 @@ class Projects::LabelsController < Projects::ApplicationController
@label = @project.labels.create(label_params)
if @label.valid?
- redirect_to project_labels_path(@project)
+ redirect_to namespace_project_labels_path(@project.namespace, @project)
else
render 'new'
end
@@ -29,7 +29,7 @@ class Projects::LabelsController < Projects::ApplicationController
def update
if @label.update_attributes(label_params)
- redirect_to project_labels_path(@project)
+ redirect_to namespace_project_labels_path(@project.namespace, @project)
else
render 'edit'
end
@@ -39,11 +39,12 @@ class Projects::LabelsController < Projects::ApplicationController
Gitlab::IssuesLabels.generate(@project)
if params[:redirect] == 'issues'
- redirect_to project_issues_path(@project)
+ redirect_to namespace_project_issues_path(@project.namespace, @project)
elsif params[:redirect] == 'merge_requests'
- redirect_to project_merge_requests_path(@project)
+ redirect_to namespace_project_merge_requests_path(@project.namespace,
+ @project)
else
- redirect_to project_labels_path(@project)
+ redirect_to namespace_project_labels_path(@project.namespace, @project)
end
end
@@ -51,7 +52,10 @@ class Projects::LabelsController < Projects::ApplicationController
@label.destroy
respond_to do |format|
- format.html { redirect_to project_labels_path(@project), notice: 'Label was removed' }
+ format.html do
+ redirect_to(namespace_project_labels_path(@project.namespace, @project),
+ notice: 'Label was removed')
+ end
format.js
end
end
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 01be318ede2..98e4775e409 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -78,7 +78,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request = MergeRequests::CreateService.new(project, current_user, merge_request_params).execute
if @merge_request.valid?
- redirect_to project_merge_request_path(@merge_request.target_project, @merge_request), notice: 'Merge request was successfully created.'
+ redirect_to(
+ namespace_project_merge_request_path(@merge_request.target_project.namespace,
+ @merge_request.target_project,
+ @merge_request),
+ notice: 'Merge request was successfully created.'
+ )
else
@source_project = @merge_request.source_project
@target_project = @merge_request.target_project
@@ -93,7 +98,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
respond_to do |format|
format.js
format.html do
- redirect_to [@merge_request.target_project, @merge_request], notice: 'Merge request was successfully updated.'
+ redirect_to([@merge_request.target_project.namespace.becomes(Namespace),
+ @merge_request.target_project, @merge_request],
+ notice: 'Merge request was successfully updated.')
end
end
else
diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb
index 95801f8b8fb..97eaabb15c3 100644
--- a/app/controllers/projects/milestones_controller.rb
+++ b/app/controllers/projects/milestones_controller.rb
@@ -40,7 +40,8 @@ class Projects::MilestonesController < Projects::ApplicationController
@milestone = Milestones::CreateService.new(project, current_user, milestone_params).execute
if @milestone.save
- redirect_to project_milestone_path(@project, @milestone)
+ redirect_to namespace_project_milestone_path(@project.namespace,
+ @project, @milestone)
else
render "new"
end
@@ -67,7 +68,7 @@ class Projects::MilestonesController < Projects::ApplicationController
@milestone.destroy
respond_to do |format|
- format.html { redirect_to project_milestones_path }
+ format.html { redirect_to namespace_project_milestones_path }
format.js { render nothing: true }
end
end
diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb
index f45df38b87c..ac36ac6fcd3 100644
--- a/app/controllers/projects/protected_branches_controller.rb
+++ b/app/controllers/projects/protected_branches_controller.rb
@@ -12,7 +12,8 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
def create
@project.protected_branches.create(protected_branch_params)
- redirect_to project_protected_branches_path(@project)
+ redirect_to namespace_project_protected_branches_path(@project.namespace,
+ @project)
end
def update
@@ -37,7 +38,7 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
@project.protected_branches.find(params[:id]).destroy
respond_to do |format|
- format.html { redirect_to project_protected_branches_path }
+ format.html { redirect_to namespace_project_protected_branches_path }
format.js { render nothing: true }
end
end
diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb
index 0adecded17e..67acf45ab7f 100644
--- a/app/controllers/projects/refs_controller.rb
+++ b/app/controllers/projects/refs_controller.rb
@@ -9,13 +9,15 @@ class Projects::RefsController < Projects::ApplicationController
respond_to do |format|
format.html do
new_path = if params[:destination] == "tree"
- project_tree_path(@project, (@id))
+ namespace_project_tree_path(@project.namespace, @project,
+ (@id))
elsif params[:destination] == "blob"
- project_blob_path(@project, (@id))
+ namespace_project_blob_path(@project.namespace, @project,
+ (@id))
elsif params[:destination] == "graph"
- project_network_path(@project, @id, @options)
+ namespace_project_network_path(@project.namespace, @project, @id, @options)
else
- project_commits_path(@project, @id)
+ namespace_project_commits_path(@project.namespace, @project, @id)
end
redirect_to new_path
diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb
index 320c3965265..245dfb7bb9a 100644
--- a/app/controllers/projects/repositories_controller.rb
+++ b/app/controllers/projects/repositories_controller.rb
@@ -7,7 +7,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
def create
@project.create_repository
- redirect_to @project
+ redirect_to namespace_project_path(@project.namespace, @project)
end
def archive
diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb
index 2b3e70f7bdb..5c29a6550f5 100644
--- a/app/controllers/projects/services_controller.rb
+++ b/app/controllers/projects/services_controller.rb
@@ -17,8 +17,11 @@ class Projects::ServicesController < Projects::ApplicationController
def update
if @service.update_attributes(service_params)
- redirect_to edit_project_service_path(@project, @service.to_param),
- notice: 'Successfully updated.'
+ redirect_to(
+ edit_namespace_project_service_path(@project.namespace, @project,
+ @service.to_param, notice:
+ 'Successfully updated.')
+ )
else
render 'edit'
end
diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb
index 25c887deafa..6c250e4ffed 100644
--- a/app/controllers/projects/snippets_controller.rb
+++ b/app/controllers/projects/snippets_controller.rb
@@ -32,7 +32,8 @@ class Projects::SnippetsController < Projects::ApplicationController
@snippet.author = current_user
if @snippet.save
- redirect_to project_snippet_path(@project, @snippet)
+ redirect_to namespace_project_snippet_path(@project.namespace, @project,
+ @snippet)
else
respond_with(@snippet)
end
@@ -43,7 +44,7 @@ class Projects::SnippetsController < Projects::ApplicationController
def update
if @snippet.update_attributes(snippet_params)
- redirect_to project_snippet_path(@project, @snippet)
+ redirect_to namespace_project_snippet_path(@project.namespace, @project, @snippet)
else
respond_with(@snippet)
end
@@ -60,7 +61,7 @@ class Projects::SnippetsController < Projects::ApplicationController
@snippet.destroy
- redirect_to project_snippets_path(@project)
+ redirect_to namespace_project_snippets_path(@project.namespace, @project)
end
def raw
diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb
index 22eb8f67f9a..08c7ce3f37d 100644
--- a/app/controllers/projects/tags_controller.rb
+++ b/app/controllers/projects/tags_controller.rb
@@ -16,7 +16,7 @@ class Projects::TagsController < Projects::ApplicationController
if result[:status] == :success
@tag = result[:tag]
- redirect_to project_tags_path(@project)
+ redirect_to namespace_project_tags_path(@project.namespace, @project)
else
@error = result[:message]
render action: 'new'
@@ -31,7 +31,7 @@ class Projects::TagsController < Projects::ApplicationController
end
respond_to do |format|
- format.html { redirect_to project_tags_path }
+ format.html { redirect_to namespace_project_tags_path }
format.js
end
end
diff --git a/app/controllers/projects/team_members_controller.rb b/app/controllers/projects/team_members_controller.rb
index 0791e6080fb..71b0ab7ee82 100644
--- a/app/controllers/projects/team_members_controller.rb
+++ b/app/controllers/projects/team_members_controller.rb
@@ -21,7 +21,8 @@ class Projects::TeamMembersController < Projects::ApplicationController
if params[:redirect_to]
redirect_to params[:redirect_to]
else
- redirect_to project_team_index_path(@project)
+ redirect_to namespace_project_team_index_path(@project.namespace,
+ @project)
end
end
@@ -32,7 +33,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
unless @user_project_relation.valid?
flash[:alert] = "User should have at least one role"
end
- redirect_to project_team_index_path(@project)
+ redirect_to namespace_project_team_index_path(@project.namespace, @project)
end
def destroy
@@ -40,7 +41,10 @@ class Projects::TeamMembersController < Projects::ApplicationController
@user_project_relation.destroy
respond_to do |format|
- format.html { redirect_to project_team_index_path(@project) }
+ format.html do
+ redirect_to namespace_project_team_index_path(@project.namespace,
+ @project)
+ end
format.js { render nothing: true }
end
end
@@ -59,7 +63,8 @@ class Projects::TeamMembersController < Projects::ApplicationController
status = @project.team.import(giver)
notice = status ? "Successfully imported" : "Import failed"
- redirect_to project_team_index_path(project), notice: notice
+ redirect_to(namespace_project_team_index_path(project.namespace, project),
+ notice: notice)
end
protected
diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb
index 70cd5a62ff5..b23010bf595 100644
--- a/app/controllers/projects/tree_controller.rb
+++ b/app/controllers/projects/tree_controller.rb
@@ -9,7 +9,10 @@ class Projects::TreeController < Projects::ApplicationController
def show
if tree.entries.empty?
if @repository.blob_at(@commit.id, @path)
- redirect_to project_blob_path(@project, File.join(@ref, @path)) and return
+ redirect_to(
+ namespace_project_blob_path(@project.namespace, @project,
+ File.join(@ref, @path))
+ ) and return
else
return not_found!
end
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb
index 0145207bf6f..69824dca944 100644
--- a/app/controllers/projects/wikis_controller.rb
+++ b/app/controllers/projects/wikis_controller.rb
@@ -45,7 +45,7 @@ class Projects::WikisController < Projects::ApplicationController
return render('empty') unless can?(current_user, :write_wiki, @project)
if @page.update(content, format, message)
- redirect_to [@project, @page], notice: 'Wiki was successfully updated.'
+ redirect_to [@project.namespace.becomes(Namespace), @project, @page], notice: 'Wiki was successfully updated.'
else
render 'edit'
end
@@ -55,7 +55,10 @@ class Projects::WikisController < Projects::ApplicationController
@page = WikiPage.new(@project_wiki)
if @page.create(wiki_params)
- redirect_to project_wiki_path(@project, @page), notice: 'Wiki was successfully updated.'
+ redirect_to(
+ namespace_project_wiki_path(@project.namespace, @project, @page),
+ notice: 'Wiki was successfully updated.'
+ )
else
render action: "edit"
end
@@ -65,7 +68,10 @@ class Projects::WikisController < Projects::ApplicationController
@page = @project_wiki.find_page(params[:id])
unless @page
- redirect_to(project_wiki_path(@project, :home), notice: "Page not found")
+ redirect_to(
+ namespace_project_wiki_path(@project.namespace, @project, :home),
+ notice: "Page not found"
+ )
end
end
@@ -73,7 +79,10 @@ class Projects::WikisController < Projects::ApplicationController
@page = @project_wiki.find_page(params[:id])
@page.delete if @page
- redirect_to project_wiki_path(@project, :home), notice: "Page was successfully deleted"
+ redirect_to(
+ namespace_project_wiki_path(@project.namespace, @project, :home),
+ notice: "Page was successfully deleted"
+ )
end
def git_access
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 74e188e484d..3063f00adeb 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -22,7 +22,10 @@ class ProjectsController < ApplicationController
@project = ::Projects::CreateService.new(current_user, project_params).execute
if @project.saved?
- redirect_to project_path(@project), notice: 'Project was successfully created.'
+ redirect_to(
+ namespace_project_path(@project.namespace, @project),
+ notice: 'Project was successfully created.'
+ )
else
render 'new'
end
@@ -34,7 +37,12 @@ class ProjectsController < ApplicationController
respond_to do |format|
if status
flash[:notice] = 'Project was successfully updated.'
- format.html { redirect_to edit_project_path(@project), notice: 'Project was successfully updated.' }
+ format.html do
+ redirect_to(
+ edit_namespace_project_path(@project.namespace, @project),
+ notice: 'Project was successfully updated.'
+ )
+ end
format.js
else
format.html { render 'edit', layout: 'project_settings' }
@@ -44,7 +52,8 @@ class ProjectsController < ApplicationController
end
def transfer
- ::Projects::TransferService.new(project, current_user, project_params).execute
+ transfer_params = params.permit(:new_namespace_id)
+ ::Projects::TransferService.new(project, current_user, transfer_params).execute
if @project.errors[:namespace_id].present?
flash[:alert] = @project.errors[:namespace_id].first
end
@@ -52,7 +61,7 @@ class ProjectsController < ApplicationController
def show
if @project.import_in_progress?
- redirect_to project_import_path(@project)
+ redirect_to namespace_project_import_path(@project.namespace, @project)
return
end
@@ -93,7 +102,7 @@ class ProjectsController < ApplicationController
flash[:alert] = 'Project deleted.'
if request.referer.include?('/admin')
- redirect_to admin_projects_path
+ redirect_to admin_namespace_projects_path
else
redirect_to projects_dashboard_path
end
@@ -124,7 +133,7 @@ class ProjectsController < ApplicationController
@project.archive!
respond_to do |format|
- format.html { redirect_to @project }
+ format.html { redirect_to namespace_project_path(@project.namespace, @project) }
end
end
@@ -133,7 +142,7 @@ class ProjectsController < ApplicationController
@project.unarchive!
respond_to do |format|
- format.html { redirect_to @project }
+ format.html { redirect_to namespace_project_path(@project.namespace, @project) }
end
end
diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb
index 508c2a6221a..b096c3913e1 100644
--- a/app/controllers/uploads_controller.rb
+++ b/app/controllers/uploads_controller.rb
@@ -1,4 +1,7 @@
class UploadsController < ApplicationController
+ skip_before_filter :authenticate_user!, :reject_blocked!
+ before_filter :authorize_access
+
def show
model = params[:model].camelize.constantize.find(params[:id])
uploader = model.send(params[:mounted_as])
@@ -12,4 +15,10 @@ class UploadsController < ApplicationController
disposition = uploader.image? ? 'inline' : 'attachment'
send_file uploader.file.path, disposition: disposition
end
+
+ def authorize_access
+ unless params[:mounted_as] == 'avatar'
+ authenticate_user! && reject_blocked!
+ end
+ end
end