2018-09-23 19:44:14 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-03-12 15:08:48 +00:00
|
|
|
class Groups::ApplicationController < ApplicationController
|
2017-05-01 20:46:30 +00:00
|
|
|
include RoutableActions
|
2017-12-11 14:21:06 +00:00
|
|
|
include ControllerWithCrossProjectAccessCheck
|
2020-11-23 15:09:37 +00:00
|
|
|
include SortingHelper
|
|
|
|
include SortingPreference
|
2017-05-01 20:46:30 +00:00
|
|
|
|
2015-05-01 08:39:11 +00:00
|
|
|
layout 'group'
|
2016-03-20 20:03:53 +00:00
|
|
|
|
|
|
|
skip_before_action :authenticate_user!
|
2015-11-13 18:20:48 +00:00
|
|
|
before_action :group
|
2020-11-23 15:09:37 +00:00
|
|
|
before_action :set_sorting
|
2017-12-11 14:21:06 +00:00
|
|
|
requires_cross_project_access
|
2015-03-12 15:08:48 +00:00
|
|
|
|
|
|
|
private
|
2015-11-13 18:20:48 +00:00
|
|
|
|
|
|
|
def group
|
2017-05-05 00:06:01 +00:00
|
|
|
@group ||= find_routable!(Group, params[:group_id] || params[:id])
|
2016-03-20 20:03:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def group_projects
|
2017-03-03 10:35:04 +00:00
|
|
|
@projects ||= GroupProjectsFinder.new(group: group, current_user: current_user).execute
|
2015-03-13 15:27:51 +00:00
|
|
|
end
|
2015-11-13 18:20:48 +00:00
|
|
|
|
2020-01-29 09:08:49 +00:00
|
|
|
def group_projects_with_subgroups
|
|
|
|
@group_projects_with_subgroups ||= GroupProjectsFinder.new(
|
|
|
|
group: group,
|
|
|
|
current_user: current_user,
|
|
|
|
options: { include_subgroups: true }
|
|
|
|
).execute
|
|
|
|
end
|
|
|
|
|
2015-03-12 15:08:48 +00:00
|
|
|
def authorize_admin_group!
|
2015-04-10 12:39:10 +00:00
|
|
|
unless can?(current_user, :admin_group, group)
|
2020-07-11 00:09:17 +00:00
|
|
|
render_404
|
2015-03-12 15:08:48 +00:00
|
|
|
end
|
|
|
|
end
|
2015-11-13 18:20:48 +00:00
|
|
|
|
2020-07-01 21:08:51 +00:00
|
|
|
def authorize_create_deploy_token!
|
|
|
|
unless can?(current_user, :create_deploy_token, group)
|
2020-07-11 00:09:17 +00:00
|
|
|
render_404
|
2020-07-01 21:08:51 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_destroy_deploy_token!
|
|
|
|
unless can?(current_user, :destroy_deploy_token, group)
|
2020-07-11 00:09:17 +00:00
|
|
|
render_404
|
2020-07-01 21:08:51 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-31 12:15:49 +00:00
|
|
|
def authorize_admin_group_member!
|
|
|
|
unless can?(current_user, :admin_group_member, group)
|
2020-07-11 00:09:17 +00:00
|
|
|
render_403
|
2015-07-31 12:15:49 +00:00
|
|
|
end
|
|
|
|
end
|
2017-05-18 23:23:05 +00:00
|
|
|
|
|
|
|
def build_canonical_path(group)
|
|
|
|
params[:group_id] = group.to_param
|
2017-08-15 17:44:37 +00:00
|
|
|
|
2018-04-28 10:35:16 +00:00
|
|
|
url_for(safe_params)
|
2017-05-18 23:23:05 +00:00
|
|
|
end
|
2020-11-23 15:09:37 +00:00
|
|
|
|
|
|
|
def set_sorting
|
|
|
|
if has_project_list?
|
|
|
|
@group_projects_sort = set_sort_order(Project::SORTING_PREFERENCE_FIELD, sort_value_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_project_list?
|
|
|
|
false
|
|
|
|
end
|
2015-03-12 15:08:48 +00:00
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
|
|
|
Groups::ApplicationController.prepend_if_ee('EE::Groups::ApplicationController')
|