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]
|
|
|
|
@project = Project.find_with_namespace(id)
|
|
|
|
|
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)
|
|
|
|
redirect_to project_tree_path(@project, @ref), notice: "This action is not allowed unless you are on top of a branch"
|
|
|
|
end
|
|
|
|
end
|
2013-01-23 09:14:20 -05:00
|
|
|
end
|