From 2660e83c97c46b7303a71b1110c693fbfbc9662c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 30 Dec 2014 11:30:56 +0200 Subject: Add group filtering by name for API Signed-off-by: Dmitriy Zaporozhets --- lib/api/groups.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/api/groups.rb') diff --git a/lib/api/groups.rb b/lib/api/groups.rb index f0ab6938b1c..a2d915a7eca 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -25,11 +25,14 @@ module API # Example Request: # GET /groups get do - if current_user.admin - @groups = paginate Group - else - @groups = paginate current_user.groups - end + @groups = if current_user.admin + Group.all + else + current_user.groups + end + + @groups = @groups.search(params[:search]) if params[:search].present? + @groups = paginate @groups present @groups, with: Entities::Group end -- cgit v1.2.1 From ed464edabeb62e35363ebadd0a5bb5ff394b6781 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 30 Dec 2014 14:29:55 +0100 Subject: Message for api files and groups. --- lib/api/groups.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api/groups.rb') diff --git a/lib/api/groups.rb b/lib/api/groups.rb index a2d915a7eca..cee51c82ad5 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -54,7 +54,7 @@ module API if @group.save present @group, with: Entities::Group else - not_found! + render_api_error!("Failed to save group #{@group.errors.messages}", 422) end end @@ -97,7 +97,7 @@ module API if result present group else - not_found! + render_api_error!("Failed to transfer project #{project.errors.messages}", 422) end end end -- cgit v1.2.1 From cd0aed3d54fc01d0c361a8cf282d2de48297f66a Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 7 Jan 2015 10:46:00 +0100 Subject: Add a message when unable to save an object through api. --- lib/api/groups.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api/groups.rb') diff --git a/lib/api/groups.rb b/lib/api/groups.rb index cee51c82ad5..bda60b3b7d5 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -54,7 +54,7 @@ module API if @group.save present @group, with: Entities::Group else - render_api_error!("Failed to save group #{@group.errors.messages}", 422) + render_api_error!("Failed to save group #{@group.errors.messages}", 400) end end @@ -97,7 +97,7 @@ module API if result present group else - render_api_error!("Failed to transfer project #{project.errors.messages}", 422) + render_api_error!("Failed to transfer project #{project.errors.messages}", 400) end end end -- cgit v1.2.1 From 6ac8bb0f7ccd7b1f10909aea62b1d8493fc0574a Mon Sep 17 00:00:00 2001 From: Daniel Serodio Date: Tue, 16 Dec 2014 20:03:28 -0200 Subject: Add description attribute to group API (GET and POST) --- lib/api/groups.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/groups.rb') diff --git a/lib/api/groups.rb b/lib/api/groups.rb index bda60b3b7d5..730dfad52c8 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -47,7 +47,7 @@ module API authenticated_as_admin! required_attributes! [:name, :path] - attrs = attributes_for_keys [:name, :path] + attrs = attributes_for_keys [:name, :path, :description] @group = Group.new(attrs) @group.owner = current_user -- cgit v1.2.1 From 4e97f26649a7756bef843fca74e3c58eadd117e1 Mon Sep 17 00:00:00 2001 From: jubianchi Date: Fri, 30 Jan 2015 10:46:08 +0100 Subject: Acces groups with their path in API --- lib/api/groups.rb | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'lib/api/groups.rb') diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 730dfad52c8..384a28e41f5 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -4,22 +4,6 @@ module API before { authenticate! } resource :groups do - helpers do - def find_group(id) - group = Group.find(id) - - if can?(current_user, :read_group, group) - group - else - render_api_error!("403 Forbidden - #{current_user.username} lacks sufficient access to #{group.name}", 403) - end - end - - def validate_access_level?(level) - Gitlab::Access.options_with_owner.values.include? level.to_i - end - end - # Get a groups list # # Example Request: -- cgit v1.2.1 From 24d939afb9816f3de2ca247de82f96ca32de3612 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 17 Feb 2015 16:23:44 -0800 Subject: Remove Group#owner_id from API since it is not used any more --- lib/api/groups.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/groups.rb') diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 384a28e41f5..a92abd4b690 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -33,9 +33,9 @@ module API attrs = attributes_for_keys [:name, :path, :description] @group = Group.new(attrs) - @group.owner = current_user if @group.save + @group.add_owner(current_user) present @group, with: Entities::Group else render_api_error!("Failed to save group #{@group.errors.messages}", 400) -- cgit v1.2.1