gitlab-org--gitlab-foss/app/controllers/groups/application_controller.rb
Dmitriy Zaporozhets 83232be0e1
Add nested groups support on data level
* add parent_id field to namespaces table to store relation with nested groups
* create routes table to keep information about full path of every group and project
* project/group lookup by full path from routes table

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-12-08 11:47:16 +02:00

43 lines
852 B
Ruby

class Groups::ApplicationController < ApplicationController
layout 'group'
skip_before_action :authenticate_user!
before_action :group
private
def group
unless @group
id = params[:group_id] || params[:id]
@group = Group.find_by_full_path(id)
unless @group && can?(current_user, :read_group, @group)
@group = nil
if current_user.nil?
authenticate_user!
else
render_404
end
end
end
@group
end
def group_projects
@projects ||= GroupProjectsFinder.new(group).execute(current_user)
end
def authorize_admin_group!
unless can?(current_user, :admin_group, group)
return render_404
end
end
def authorize_admin_group_member!
unless can?(current_user, :admin_group_member, group)
return render_403
end
end
end