Build Project in context of Namespace if available

This commit is contained in:
Rubén Dávila 2017-08-25 17:09:15 -05:00 committed by Mike Greiling
parent b7b49c4a15
commit b63c08b263
1 changed files with 10 additions and 1 deletions

View File

@ -3,6 +3,7 @@ class ProjectsController < Projects::ApplicationController
include ExtractsPath
before_action :authenticate_user!, except: [:index, :show, :activity, :refs]
before_action :namespace, only: [:new]
before_action :project, except: [:index, :new, :create]
before_action :repository, except: [:index, :new, :create]
before_action :assign_ref_vars, only: [:show], if: :repo_exists?
@ -20,7 +21,7 @@ class ProjectsController < Projects::ApplicationController
end
def new
@project = Project.new
build_project
end
def edit
@ -395,4 +396,12 @@ class ProjectsController < Projects::ApplicationController
def project_export_enabled
render_404 unless current_application_settings.project_export_enabled?
end
def namespace
@namespace ||= Namespace.find(params[:namespace_id]) if params[:namespace_id].present?
end
def build_project
@project ||= namespace ? namespace.projects.new : Project.new
end
end