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.
This commit is contained in:
parent
890ffac61b
commit
88abe1ec55
1 changed files with 9 additions and 1 deletions
|
@ -66,6 +66,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 = {
|
||||||
|
@ -161,7 +169,7 @@ module API
|
||||||
group = find_group!(params[:id])
|
group = find_group!(params[:id])
|
||||||
authorize! :admin_group, group
|
authorize! :admin_group, group
|
||||||
|
|
||||||
if ::Groups::UpdateService.new(group, current_user, declared_params(include_missing: false)).execute
|
if update_group(group)
|
||||||
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)
|
||||||
|
|
Loading…
Reference in a new issue