debian-mirror-gitlab/app/controllers/projects/application_controller.rb

39 lines
944 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class Projects::ApplicationController < ApplicationController
2015-09-11 14:41:01 +05:30
before_action :project
before_action :repository
layout 'project'
2014-09-02 18:07:02 +05:30
def authenticate_user!
# Restrict access to Projects area only
# for non-signed users
if !current_user
id = params[:project_id] || params[:id]
2015-04-26 12:48:37 +05:30
project_with_namespace = "#{params[:namespace_id]}/#{id}"
@project = Project.find_with_namespace(project_with_namespace)
2014-09-02 18:07:02 +05:30
return if @project && @project.public?
end
super
end
def require_branch_head
unless @repository.branch_names.include?(@ref)
2015-04-26 12:48:37 +05:30
redirect_to(
namespace_project_tree_path(@project.namespace, @project, @ref),
notice: "This action is not allowed unless you are on top of a branch"
)
2014-09-02 18:07:02 +05:30
end
end
2015-10-24 18:46:33 +05:30
private
def ci_enabled
2015-11-26 14:37:03 +05:30
return render_404 unless @project.builds_enabled?
2015-10-24 18:46:33 +05:30
end
def ci_project
@ci_project ||= @project.ensure_gitlab_ci_project
end
2014-09-02 18:07:02 +05:30
end