#692:added index action for Groups API
This commit is contained in:
parent
0c475b35f7
commit
d99a2104ce
|
@ -0,0 +1,21 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class Api::V1::GroupsController < Api::V1::BaseController
|
||||
|
||||
before_filter :authenticate_user!
|
||||
skip_before_filter :authenticate_user!, :only => [:show] if APP_CONFIG['anonymous_access']
|
||||
load_and_authorize_resource :group
|
||||
|
||||
def index
|
||||
# accessible_by(current_ability)
|
||||
@groups = current_user.groups.paginate(paginate_params)
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
json.groups @groups do |json, group|
|
||||
json.(group, :id, :uname, :own_projects_count, :description)
|
||||
json.created_at group.created_at.to_i
|
||||
json.updated_at group.updated_at.to_i
|
||||
json.owner do |json_owner|
|
||||
json_owner.(group.owner, :id, :name)
|
||||
json_owner.type 'User'
|
||||
json_owner.url api_v1_user_path(group.owner.id, :format => :json)
|
||||
end
|
||||
json.avatar_url avatar_url(group, :big)
|
||||
json.url api_v1_group_path(group.id, :format => :json)
|
||||
json.html_url group_path(group.uname)
|
||||
end
|
||||
|
||||
json.url api_v1_groups_path(:format => :json)
|
|
@ -55,6 +55,14 @@ Rosa::Application.routes.draw do
|
|||
put :notifiers
|
||||
}
|
||||
end
|
||||
resources :groups, :only => [:index, :show, :update, :create, :destroy] do
|
||||
member {
|
||||
get :members
|
||||
put :add_member
|
||||
delete :remove_member
|
||||
put :update_member
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue