Commit 3dff1ef3 by John Doe

integrated permission removal path

parent bccc8aec
......@@ -8,7 +8,7 @@ class PermissionsController < ApplicationController
# GET /permissions.json
def index
# return permissions for nilm specified by nilm_id
@permissions = @nilm.permissions
@permissions = @nilm.permissions.includes(:user, :user_group)
end
# POST /permissions
......
......@@ -25,6 +25,16 @@ class Permission < ApplicationRecord
end
end
def target_type
if self.user_id?
return 'user'
elsif self.user_group_id?
return 'group'
else
return 'unknown'
end
end
def self.json_keys
[:id, :nilm_id, :role]
end
......
json.extract! permission, *Permission.json_keys
json.name permission.target_name
json.data do
json.extract! @permission, *Permission.json_keys
json.name @permission.target_name
json.target_name @permission.target_name
json.target_type @permission.target_type
end
json.partial! "helpers/messages", service: @service
json.array!(@permissions) do |permission|
json.extract! permission, *Permission.json_keys
json.name permission.target_name
json.target_name permission.target_name
json.target_type permission.target_type
json.removable permission.user_id!=current_user.id
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment