2013-01-23 09:14:20 -05:00
|
|
|
class Projects::ApplicationController < ApplicationController
|
2013-03-24 11:12:28 -04:00
|
|
|
before_filter :project
|
|
|
|
before_filter :repository
|
2013-09-24 08:58:39 -04:00
|
|
|
layout :determine_layout
|
|
|
|
|
|
|
|
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 13:02:58 -05:00
|
|
|
project_with_namespace = "#{params[:namespace_id]}/#{id}"
|
|
|
|
@project = Project.find_with_namespace(project_with_namespace)
|
2013-09-24 08:58:39 -04:00
|
|
|
|
2013-11-06 10:13:21 -05:00
|
|
|
return if @project && @project.public?
|
2013-09-24 08:58:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def determine_layout
|
|
|
|
if current_user
|
|
|
|
'projects'
|
|
|
|
else
|
2013-09-24 15:14:28 -04:00
|
|
|
'public_projects'
|
2013-09-24 08:58:39 -04:00
|
|
|
end
|
|
|
|
end
|
2013-11-05 05:21:11 -05:00
|
|
|
|
|
|
|
def require_branch_head
|
|
|
|
unless @repository.branch_names.include?(@ref)
|
2015-01-24 13:02:58 -05:00
|
|
|
redirect_to(
|
|
|
|
namespace_project_tree_path(@project.namespace, @project, @ref),
|
|
|
|
notice: "This action is not allowed unless you are on top of a branch"
|
|
|
|
)
|
2013-11-05 05:21:11 -05:00
|
|
|
end
|
|
|
|
end
|
2013-01-23 09:14:20 -05:00
|
|
|
end
|