Commit a38bdc91 authored by Douwe Maan's avatar Douwe Maan
Browse files

Create and use project path helpers that only need a project, no namespace

parent 3a948152a258
......@@ -40,10 +40,10 @@
::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
@project.reload
redirect_to admin_namespace_project_path(@project.namespace, @project)
redirect_to admin_project_path(@project)
end
def repository_check
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
redirect_to(
......@@ -44,10 +44,10 @@
end
def repository_check
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
redirect_to(
admin_namespace_project_path(@project.namespace, @project),
admin_project_path(@project),
notice: 'Repository check was triggered.'
)
end
......
......@@ -78,8 +78,7 @@
end
def new_merge_request_path
namespace_project_new_merge_request_path(
@project_to_commit_into.namespace,
project_new_merge_request_path(
@project_to_commit_into,
merge_request: {
source_project_id: @project_to_commit_into.id,
......@@ -91,7 +90,7 @@
end
def existing_merge_request_path
namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
project_merge_request_path(@project, @merge_request)
end
def merge_request_exists?
......
......@@ -45,7 +45,7 @@
def milestone_redirect_path
if @project
namespace_project_milestone_path(@project.namespace, @project, @milestone)
project_milestone_path(@project, @milestone)
elsif @group
group_milestone_path(@group, @milestone.safe_title, title: @milestone.title)
else
......
......@@ -2,6 +2,6 @@
extend ActiveSupport::Concern
def redirect_to_repository_settings(project)
redirect_to namespace_project_settings_repository_path(project.namespace, project)
redirect_to project_settings_repository_path(project)
end
end
......@@ -9,5 +9,5 @@
def mark_as_spam
if SpamService.new(spammable).mark_as_spam!
redirect_to spammable, notice: "#{spammable.spammable_entity_type.titlecase} was submitted to Akismet successfully."
redirect_to spammable_path, notice: "#{spammable.spammable_entity_type.titlecase} was submitted to Akismet successfully."
else
......@@ -13,5 +13,5 @@
else
redirect_to spammable, alert: 'Error with Akismet. Please check the logs for more info.'
redirect_to spammable_path, alert: 'Error with Akismet. Please check the logs for more info.'
end
end
......@@ -25,7 +25,7 @@
def recaptcha_check_with_fallback(&fallback)
if spammable.valid?
redirect_to spammable
redirect_to spammable_path
elsif render_recaptcha?
ensure_spam_config_loaded!
......@@ -56,6 +56,10 @@
raise NotImplementedError, "#{self.class} does not implement #{__method__}"
end
def spammable_path
raise NotImplementedError, "#{self.class} does not implement #{__method__}"
end
def authorize_submit_spammable!
access_denied! unless current_user.admin?
end
......
......@@ -63,7 +63,7 @@
when Project
project = member.source
label = "project #{project.name_with_namespace}"
path = namespace_project_path(project.namespace, project)
path = project_path(project)
when Group
group = member.source
label = "group #{group.name}"
......
......@@ -76,9 +76,9 @@
def require_non_empty_project
# Be sure to return status code 303 to avoid a double DELETE:
# http://api.rubyonrails.org/classes/ActionController/Redirecting.html
redirect_to namespace_project_path(@project.namespace, @project), status: 303 if @project.empty_repo?
redirect_to project_path(@project), status: 303 if @project.empty_repo?
end
def require_branch_head
unless @repository.branch_exists?(@ref)
redirect_to(
......@@ -80,9 +80,9 @@
end
def require_branch_head
unless @repository.branch_exists?(@ref)
redirect_to(
namespace_project_tree_path(@project.namespace, @project, @ref),
project_tree_path(@project, @ref),
notice: "This action is not allowed unless you are on a branch"
)
end
......
......@@ -46,7 +46,7 @@
def keep
build.keep_artifacts!
redirect_to namespace_project_job_path(project.namespace, project, build)
redirect_to project_job_path(project, build)
end
def latest_succeeded
......
......@@ -27,5 +27,5 @@
def create
create_commit(Files::CreateService, success_notice: "The file has been successfully created.",
success_path: -> { namespace_project_blob_path(@project.namespace, @project, File.join(@branch_name, @file_path)) },
success_path: -> { project_blob_path(@project, File.join(@branch_name, @file_path)) },
failure_view: :new,
......@@ -31,5 +31,5 @@
failure_view: :new,
failure_path: namespace_project_new_blob_path(@project.namespace, @project, @ref))
failure_path: project_new_blob_path(@project, @ref))
end
def show
......@@ -63,7 +63,7 @@
@path = params[:file_path] if params[:file_path].present?
create_commit(Files::UpdateService, success_path: -> { after_edit_path },
failure_view: :edit,
failure_path: namespace_project_blob_path(@project.namespace, @project, @id))
failure_path: project_blob_path(@project, @id))
rescue Files::UpdateService::FileChangedError
@conflict = true
......@@ -83,5 +83,5 @@
def destroy
create_commit(Files::DeleteService, success_notice: "The file has been successfully deleted.",
success_path: -> { namespace_project_tree_path(@project.namespace, @project, @branch_name) },
success_path: -> { project_tree_path(@project, @branch_name) },
failure_view: :show,
......@@ -87,5 +87,5 @@
failure_view: :show,
failure_path: namespace_project_blob_path(@project.namespace, @project, @id))
failure_path: project_blob_path(@project, @id))
end
def diff
......@@ -118,7 +118,7 @@
else
if tree = @repository.tree(@commit.id, @path)
if tree.entries.any?
return redirect_to namespace_project_tree_path(@project.namespace, @project, File.join(@ref, @path))
return redirect_to project_tree_path(@project, File.join(@ref, @path))
end
end
......@@ -143,6 +143,6 @@
def after_edit_path
from_merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.find_by(iid: params[:from_merge_request_iid])
if from_merge_request && @branch_name == @ref
diffs_namespace_project_merge_request_path(from_merge_request.target_project.namespace, from_merge_request.target_project, from_merge_request) +
diffs_project_merge_request_path(from_merge_request.target_project, from_merge_request) +
"##{hexdigest(@path)}"
else
......@@ -147,6 +147,6 @@
"##{hexdigest(@path)}"
else
namespace_project_blob_path(@project.namespace, @project, File.join(@branch_name, @path))
project_blob_path(@project, File.join(@branch_name, @path))
end
end
......
......@@ -52,7 +52,7 @@
redirect_to url_to_autodeploy_setup(project, branch_name),
notice: view_context.autodeploy_flash_notice(branch_name)
else
redirect_to namespace_project_tree_path(@project.namespace, @project, branch_name)
redirect_to project_tree_path(@project, branch_name)
end
else
@error = result[:message]
......@@ -62,7 +62,7 @@
format.json do
if result[:status] == :success
render json: { name: branch_name, url: namespace_project_tree_url(@project.namespace, @project, branch_name) }
render json: { name: branch_name, url: project_tree_url(@project, branch_name) }
else
render json: result[:messsage], status: :unprocessable_entity
end
......@@ -79,7 +79,7 @@
flash_type = result[:status] == :error ? :alert : :notice
flash[flash_type] = result[:message]
redirect_to namespace_project_branches_path(@project.namespace, @project), status: 303
redirect_to project_branches_path(@project), status: 303
end
format.js { render nothing: true, status: result[:return_code] }
......@@ -90,7 +90,7 @@
def destroy_all_merged
DeleteMergedBranchesService.new(@project, current_user).async_execute
redirect_to namespace_project_branches_path(@project.namespace, @project),
redirect_to project_branches_path(@project),
notice: 'Merged branches are being deleted. This can take some time depending on the number of branches. Please refresh the page to see changes.'
end
......@@ -106,8 +106,7 @@
end
def url_to_autodeploy_setup(project, branch_name)
namespace_project_new_blob_path(
project.namespace,
project_new_blob_path(
project,
branch_name,
file_name: '.gitlab-ci.yml',
......
......@@ -7,7 +7,7 @@
before_action :validate_artifacts!
def download
redirect_to download_namespace_project_job_artifacts_path(project.namespace, project, job)
redirect_to download_project_job_artifacts_path(project, job)
end
def browse
......@@ -11,7 +11,7 @@
end
def browse
redirect_to browse_namespace_project_job_artifacts_path(project.namespace, project, job, path: params[:path])
redirect_to browse_project_job_artifacts_path(project, job, path: params[:path])
end
def file
......@@ -15,7 +15,7 @@
end
def file
redirect_to file_namespace_project_job_artifacts_path(project.namespace, project, job, path: params[:path])
redirect_to file_project_job_artifacts_path(project, job, path: params[:path])
end
def raw
......@@ -19,7 +19,7 @@
end
def raw
redirect_to raw_namespace_project_job_artifacts_path(project.namespace, project, job, path: params[:path])
redirect_to raw_project_job_artifacts_path(project, job, path: params[:path])
end
def latest_succeeded
......@@ -23,7 +23,7 @@
end
def latest_succeeded
redirect_to latest_succeeded_namespace_project_artifacts_path(project.namespace, project, job, ref_name_and_path: params[:ref_name_and_path], job: params[:job])
redirect_to latest_succeeded_project_artifacts_path(project, job, ref_name_and_path: params[:ref_name_and_path], job: params[:job])
end
private
......
......@@ -2,7 +2,7 @@
before_action :authorize_read_build!
def index
redirect_to namespace_project_jobs_path(project.namespace, project)
redirect_to project_jobs_path(project)
end
def show
......@@ -6,7 +6,7 @@
end
def show
redirect_to namespace_project_job_path(project.namespace, project, job)
redirect_to project_job_path(project, job)
end
def raw
......@@ -10,7 +10,7 @@
end
def raw
redirect_to raw_namespace_project_job_path(project.namespace, project, job)
redirect_to raw_project_job_path(project, job)
end
private
......
......@@ -80,7 +80,7 @@
end
def successful_change_path
referenced_merge_request_url || namespace_project_commits_url(@project.namespace, @project, @branch_name)
referenced_merge_request_url || project_commits_url(@project, @branch_name)
end
def failed_change_path
......@@ -84,8 +84,8 @@
end
def failed_change_path
referenced_merge_request_url || namespace_project_commit_url(@project.namespace, @project, params[:id])
referenced_merge_request_url || project_commit_url(@project, params[:id])
end
def referenced_merge_request_url
if merge_request = @commit.merged_merge_request(current_user)
......@@ -88,8 +88,8 @@
end
def referenced_merge_request_url
if merge_request = @commit.merged_merge_request(current_user)
namespace_project_merge_request_url(merge_request.target_project.namespace, merge_request.target_project, merge_request)
project_merge_request_url(merge_request.target_project, merge_request)
end
end
......
......@@ -31,5 +31,5 @@
from: params[:from].presence,
to: params[:to].presence
}
redirect_to namespace_project_compare_index_path(@project.namespace, @project, from_to_vars)
redirect_to project_compare_index_path(@project, from_to_vars)
else
......@@ -35,5 +35,5 @@
else
redirect_to namespace_project_compare_path(@project.namespace, @project,
redirect_to project_compare_path(@project,
params[:from], params[:to])
end
end
......
......@@ -63,7 +63,7 @@
@environment = project.environments.create(environment_params)
if @environment.persisted?
redirect_to namespace_project_environment_path(project.namespace, project, @environment)
redirect_to project_environment_path(project, @environment)
else
render :new
end
......@@ -71,7 +71,7 @@
def update
if @environment.update(environment_params)
redirect_to namespace_project_environment_path(project.namespace, project, @environment)
redirect_to project_environment_path(project, @environment)
else
render :edit
end
......@@ -86,7 +86,7 @@
if stop_action
polymorphic_url([project.namespace.becomes(Namespace), project, stop_action])
else
namespace_project_environment_url(project.namespace, project, @environment)
project_environment_url(project, @environment)
end
respond_to do |format|
......
......@@ -44,8 +44,8 @@
if @forked_project.saved? && @forked_project.forked?
if @forked_project.import_in_progress?
redirect_to namespace_project_import_path(@forked_project.namespace, @forked_project, continue: continue_params)
redirect_to project_import_path(@forked_project, continue: continue_params)
else
if continue_params
redirect_to continue_params[:to], notice: continue_params[:notice]
else
......@@ -48,8 +48,8 @@
else
if continue_params
redirect_to continue_params[:to], notice: continue_params[:notice]
else
redirect_to namespace_project_path(@forked_project.namespace, @forked_project), notice: "The project '#{@forked_project.name}' was successfully forked."
redirect_to project_path(@forked_project), notice: "The project '#{@forked_project.name}' was successfully forked."
end
end
else
......
......@@ -29,7 +29,7 @@
end
def ci
redirect_to charts_namespace_project_pipelines_path(@project.namespace, @project)
redirect_to charts_project_pipelines_path(@project)
end
private
......
......@@ -22,7 +22,7 @@
flash[:alert] = 'Please select a group.'
end
redirect_to namespace_project_settings_members_path(project.namespace, project)
redirect_to project_settings_members_path(project)
end
def update
......@@ -36,7 +36,7 @@
respond_to do |format|
format.html do
redirect_to namespace_project_settings_members_path(project.namespace, project), status: 302
redirect_to project_settings_members_path(project), status: 302
end
format.js { head :ok }
end
......
......@@ -18,7 +18,7 @@
set_hook_execution_notice(status, message)
redirect_to edit_namespace_project_hook_path(@project.namespace, @project, @hook)
redirect_to edit_project_hook_path(@project, @hook)
end
private
......
......@@ -17,7 +17,7 @@
@hooks = @project.hooks.select(&:persisted?)
flash[:alert] = @hook.errors.full_messages.join.html_safe
end
redirect_to namespace_project_settings_integrations_path(@project.namespace, @project)
redirect_to project_settings_integrations_path(@project)
end
def edit
......@@ -26,7 +26,7 @@
def update
if hook.update_attributes(hook_params)
flash[:notice] = 'Hook was successfully updated.'
redirect_to namespace_project_settings_integrations_path(@project.namespace, @project)
redirect_to project_settings_integrations_path(@project)
else
render 'edit'
end
......@@ -47,7 +47,7 @@
def destroy
hook.destroy
redirect_to namespace_project_settings_integrations_path(@project.namespace, @project), status: 302
redirect_to project_settings_integrations_path(@project), status: 302
end
private
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment