Commit fcdf6fbf authored by Yorick Peterse's avatar Yorick Peterse

Use a method for updating groups in the API

Similar to creating groups in the groups API, EE injects custom code
just before we update an existing group. Moving the update logic to a
separate method in CE allows EE to more easily extend it.
parent 8c095fb4
...@@ -37,6 +37,20 @@ module EE ...@@ -37,6 +37,20 @@ module EE
group group
end end
override :update_group
def update_group(group)
if params[:shared_runners_minutes_limit].present? &&
group.shared_runners_minutes_limit.to_i !=
params[:shared_runners_minutes_limit].to_i
authenticated_as_admin!
end
params.delete(:file_template_project_id) unless
group.feature_available?(:custom_file_templates_for_namespace)
super
end
end end
end end
end end
......
...@@ -75,6 +75,14 @@ module API ...@@ -75,6 +75,14 @@ module API
.execute .execute
end end
def update_group(group)
# This is a separate method so that EE can extend its behaviour, without
# having to modify this code directly.
::Groups::UpdateService
.new(group, current_user, declared_params(include_missing: false))
.execute
end
def find_group_projects(params) def find_group_projects(params)
group = find_group!(params[:id]) group = find_group!(params[:id])
options = { options = {
...@@ -173,18 +181,7 @@ module API ...@@ -173,18 +181,7 @@ module API
group = find_group!(params[:id]) group = find_group!(params[:id])
authorize! :admin_group, group authorize! :admin_group, group
# Begin EE-specific block if update_group(group)
if params[:shared_runners_minutes_limit].present? &&
group.shared_runners_minutes_limit.to_i !=
params[:shared_runners_minutes_limit].to_i
authenticated_as_admin!
end
params.delete(:file_template_project_id) unless
group.feature_available?(:custom_file_templates_for_namespace)
# End EE-specific block
if ::Groups::UpdateService.new(group, current_user, declared_params(include_missing: false)).execute
present group, with: Entities::GroupDetail, current_user: current_user present group, with: Entities::GroupDetail, current_user: current_user
else else
render_validation_error!(group) render_validation_error!(group)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment