Feature #11502 » role-rest-get.patch
config/routes.rb (working copy) | ||
---|---|---|
282 | 282 |
end |
283 | 283 |
end |
284 | 284 |
resources :custom_fields, :except => :show |
285 |
resources :roles, :except => :show do
|
|
285 |
resources :roles do |
|
286 | 286 |
collection do |
287 | 287 |
match 'permissions', :via => [:get, :post] |
288 | 288 |
end |
app/controllers/roles_controller.rb (working copy) | ||
---|---|---|
19 | 19 |
layout 'admin' |
20 | 20 | |
21 | 21 |
before_filter :require_admin, :except => :index |
22 |
before_filter :require_admin_or_api_request, :only => :index |
|
23 |
before_filter :find_role, :only => [:edit, :update, :destroy] |
|
24 |
accept_api_auth :index |
|
22 |
before_filter :require_admin_or_api_request, :only => [:index, :show] |
|
23 |
before_filter :find_role, :only => [:show, :edit, :update, :destroy] |
|
25 | 24 | |
25 | ||
26 | 26 |
def index |
27 | 27 |
respond_to do |format| |
28 | 28 |
format.html { |
... | ... | |
35 | 35 |
end |
36 | 36 |
end |
37 | 37 | |
38 |
def show |
|
39 |
respond_to do |format| |
|
40 |
format.api |
|
41 |
end |
|
42 |
end |
|
43 | ||
38 | 44 |
def new |
39 | 45 |
# Prefills the form with 'Non member' role permissions |
40 | 46 |
@role = Role.new(params[:role] || {:permissions => Role.non_member.permissions}) |
app/views/roles/show.api.rsb (revision 0) | ||
---|---|---|
1 |
api.role(:id => @role.id) do |
|
2 |
api.name @role.name |
|
3 |
api.array :permissions do |
|
4 |
@role.permissions.each do |perm| |
|
5 |
api.permission(perm.to_s) |
|
6 |
end |
|
7 |
end |
|
8 |
end |