Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wattsworth
/
lumen-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3dff1ef3
authored
Feb 20, 2017
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
integrated permission removal path
parent
bccc8aec
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
5 deletions
app/controllers/permissions_controller.rb
app/models/permission.rb
app/views/permissions/_permission.json.jbuilder
app/views/permissions/create.json.jbuilder
app/views/permissions/index.json.jbuilder
app/controllers/permissions_controller.rb
View file @
3dff1ef3
...
@@ -8,7 +8,7 @@ class PermissionsController < ApplicationController
...
@@ -8,7 +8,7 @@ class PermissionsController < ApplicationController
# GET /permissions.json
# GET /permissions.json
def
index
def
index
# return permissions for nilm specified by nilm_id
# return permissions for nilm specified by nilm_id
@permissions
=
@nilm
.
permissions
@permissions
=
@nilm
.
permissions
.
includes
(
:user
,
:user_group
)
end
end
# POST /permissions
# POST /permissions
...
...
app/models/permission.rb
View file @
3dff1ef3
...
@@ -25,6 +25,16 @@ class Permission < ApplicationRecord
...
@@ -25,6 +25,16 @@ class Permission < ApplicationRecord
end
end
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
def
self
.
json_keys
[
:id
,
:nilm_id
,
:role
]
[
:id
,
:nilm_id
,
:role
]
end
end
...
...
app/views/permissions/_permission.json.jbuilder
deleted
100644 → 0
View file @
bccc8aec
json.extract! permission, *Permission.json_keys
json.name permission.target_name
app/views/permissions/create.json.jbuilder
View file @
3dff1ef3
json.data do
json.data do
json.extract! @permission, *Permission.json_keys
json.extract! @permission, *Permission.json_keys
json.name @permission.target_name
json.target_name @permission.target_name
json.target_type @permission.target_type
end
end
json.partial! "helpers/messages", service: @service
json.partial! "helpers/messages", service: @service
app/views/permissions/index.json.jbuilder
View file @
3dff1ef3
json.array!(@permissions) do |permission|
json.array!(@permissions) do |permission|
json.extract! permission, *Permission.json_keys
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
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment