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

40 lines
1,013 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),
2015-12-23 02:04:40 +05:30
notice: "This action is not allowed unless you are on a branch"
2015-04-26 12:48:37 +05:30
)
2014-09-02 18:07:02 +05:30
end
end
2015-10-24 18:46:33 +05:30
private
2016-04-02 18:10:28 +05:30
def apply_diff_view_cookie!
view = params[:view] || cookies[:diff_view]
cookies.permanent[:diff_view] = params[:view] = view if view
end
2015-12-23 02:04:40 +05:30
def builds_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
2014-09-02 18:07:02 +05:30
end