2013-01-23 09:14:20 -05:00
|
|
|
class Projects::ApplicationController < ApplicationController
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :project
|
|
|
|
before_action :repository
|
2015-04-30 13:06:18 -04:00
|
|
|
layout 'project'
|
2013-09-24 08:58:39 -04: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 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
|
|
|
|
|
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),
|
2015-12-08 16:30:40 -05:00
|
|
|
notice: "This action is not allowed unless you are on a branch"
|
2015-01-24 13:02:58 -05:00
|
|
|
)
|
2013-11-05 05:21:11 -05:00
|
|
|
end
|
|
|
|
end
|
2015-09-24 03:44:38 -04:00
|
|
|
|
2016-02-05 06:34:51 -05:00
|
|
|
private
|
2015-10-22 21:52:17 -04:00
|
|
|
|
|
|
|
def apply_diff_view_cookie!
|
|
|
|
view = params[:view] || cookies[:diff_view]
|
|
|
|
cookies.permanent[:diff_view] = params[:view] = view if view
|
|
|
|
end
|
|
|
|
|
2015-12-08 06:55:38 -05:00
|
|
|
def builds_enabled
|
2015-11-09 10:48:03 -05:00
|
|
|
return render_404 unless @project.builds_enabled?
|
2015-09-24 03:44:38 -04:00
|
|
|
end
|
2013-01-23 09:14:20 -05:00
|
|
|
end
|