2013-01-23 14:14:20 +00:00
|
|
|
class Projects::ApplicationController < ApplicationController
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :project
|
|
|
|
before_action :repository
|
2015-04-30 17:06:18 +00:00
|
|
|
layout 'project'
|
2013-09-24 12:58:39 +00:00
|
|
|
|
|
|
|
def authenticate_user!
|
|
|
|
# Restrict access to Projects area only
|
|
|
|
# for non-signed users
|
|
|
|
if !current_user
|
|
|
|
id = params[:project_id] || params[:id]
|
2015-01-24 18:02:58 +00:00
|
|
|
project_with_namespace = "#{params[:namespace_id]}/#{id}"
|
|
|
|
@project = Project.find_with_namespace(project_with_namespace)
|
2013-09-24 12:58:39 +00:00
|
|
|
|
2013-11-06 15:13:21 +00:00
|
|
|
return if @project && @project.public?
|
2013-09-24 12:58:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2013-11-05 10:21:11 +00:00
|
|
|
def require_branch_head
|
|
|
|
unless @repository.branch_names.include?(@ref)
|
2015-01-24 18:02:58 +00:00
|
|
|
redirect_to(
|
|
|
|
namespace_project_tree_path(@project.namespace, @project, @ref),
|
2015-12-08 21:30:40 +00:00
|
|
|
notice: "This action is not allowed unless you are on a branch"
|
2015-01-24 18:02:58 +00:00
|
|
|
)
|
2013-11-05 10:21:11 +00:00
|
|
|
end
|
|
|
|
end
|
2015-09-24 07:44:38 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-12-08 11:55:38 +00:00
|
|
|
def builds_enabled
|
2015-11-09 15:48:03 +00:00
|
|
|
return render_404 unless @project.builds_enabled?
|
2015-09-24 07:44:38 +00:00
|
|
|
end
|
2013-01-23 14:14:20 +00:00
|
|
|
end
|