2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
class Groups::ApplicationController < ApplicationController
|
2017-08-17 22:00:37 +05:30
|
|
|
include RoutableActions
|
2018-03-27 19:54:05 +05:30
|
|
|
include ControllerWithCrossProjectAccessCheck
|
2021-02-22 17:27:13 +05:30
|
|
|
include SortingHelper
|
|
|
|
include SortingPreference
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
layout 'group'
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
skip_before_action :authenticate_user!
|
2015-11-26 14:37:03 +05:30
|
|
|
before_action :group
|
2021-02-22 17:27:13 +05:30
|
|
|
before_action :set_sorting
|
2018-03-27 19:54:05 +05:30
|
|
|
requires_cross_project_access
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
private
|
2015-11-26 14:37:03 +05:30
|
|
|
|
|
|
|
def group
|
2021-11-11 11:23:49 +05:30
|
|
|
@group ||= find_routable!(Group, params[:group_id] || params[:id], request.fullpath)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def group_projects
|
2017-08-17 22:00:37 +05:30
|
|
|
@projects ||= GroupProjectsFinder.new(group: group, current_user: current_user).execute
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
def group_projects_with_subgroups
|
|
|
|
@group_projects_with_subgroups ||= GroupProjectsFinder.new(
|
|
|
|
group: group,
|
|
|
|
current_user: current_user,
|
|
|
|
options: { include_subgroups: true }
|
|
|
|
).execute
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def authorize_admin_group!
|
|
|
|
unless can?(current_user, :admin_group, group)
|
2020-07-28 23:09:34 +05:30
|
|
|
render_404
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
end
|
2015-11-26 14:37:03 +05:30
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
def authorize_admin_group_runners!
|
|
|
|
unless can?(current_user, :admin_group_runners, group)
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_read_group_runners!
|
|
|
|
unless can?(current_user, :read_group_runners, group)
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-02 01:45:43 +05:30
|
|
|
def authorize_create_deploy_token!
|
|
|
|
unless can?(current_user, :create_deploy_token, group)
|
2020-07-28 23:09:34 +05:30
|
|
|
render_404
|
2020-07-02 01:45:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_destroy_deploy_token!
|
|
|
|
unless can?(current_user, :destroy_deploy_token, group)
|
2020-07-28 23:09:34 +05:30
|
|
|
render_404
|
2020-07-02 01:45:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
def authorize_admin_group_member!
|
|
|
|
unless can?(current_user, :admin_group_member, group)
|
2020-07-28 23:09:34 +05:30
|
|
|
render_403
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
def build_canonical_path(group)
|
|
|
|
params[:group_id] = group.to_param
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-06-27 16:04:02 +05:30
|
|
|
url_for(safe_params)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
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-04-26 12:48:37 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
Groups::ApplicationController.prepend_mod_with('Groups::ApplicationController')
|