diff options
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/groups.rb | 32 | ||||
-rw-r--r-- | lib/api/projects.rb | 4 |
2 files changed, 33 insertions, 3 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 236d5d3bb43..9465afd3eed 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -23,15 +23,18 @@ module API # Create group. Available only for users who can create groups. # # Parameters: - # name (required) - The name of the group - # path (required) - The path of the group + # name (required) - The name of the group + # path (required) - The path of the group + # description (optional) - The details of the group + # membership_lock (optional, boolean) - Prevent adding new members to project membership within this group + # share_with_group_lock (optional, boolean) - Prevent sharing a project with another group within this group # Example Request: # POST /groups post do authorize! :create_group, current_user required_attributes! [:name, :path] - attrs = attributes_for_keys [:name, :path, :description] + attrs = attributes_for_keys [:name, :path, :description, :membership_lock, :share_with_group_lock] @group = Group.new(attrs) if @group.save @@ -51,6 +54,29 @@ module API end end + # Update group. Available only for users who can manage this group. + # + # Parameters: + # id (required) - The ID of a group + # name (required) - The name of the group + # path (required) - The path of the group + # description (optional) - The details of the group + # membership_lock (optional, boolean) - Prevent adding new members to project membership within this group + # share_with_group_lock (optional, boolean) - Prevent sharing a project with another group within this group + # Example Request: + # PUT /groups/:id + put ":id" do + attrs = attributes_for_keys [:name, :path, :description, :membership_lock, :share_with_group_lock] + @group = find_group(params[:id]) + authorize! :admin_group, @group + + if @group.update_attributes(attrs) + present @group, with: Entities::Group + else + render_api_error!("Failed to update group #{@group.errors.messages}", 400) + end + end + # Get a single group, with containing projects # # Parameters: diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 56a5f3c94f3..007d88d4853 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -264,6 +264,10 @@ module API post ":id/share" do authorize! :admin_project, user_project required_attributes! [:group_id, :group_access] + + unless user_project.allowed_to_share_with_group? + return render_api_error!("The project sharing with group is disabled") + end link = user_project.project_group_links.new link.group_id = params[:group_id] |