Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
11
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
beb0809d
authored
Aug 29, 2019
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix flake8 errors
parent
84bace71
Pipeline
#851
passed with stage
in 1 minute 21 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
recircle/instance/views.py
+5
-3
No files found.
recircle/instance/views.py
View file @
beb0809d
...
...
@@ -14,7 +14,7 @@ from authorization.mixins import AuthorizationMixin
authorization
=
{
"list"
:
{
"auth_type"
:
"filter"
,
"perms"
:
[
"use_instance"
]},
"create"
:
{
"auth_type"
:
"class"
,
"perms"
:
[
"instance.create_instance"
]
,
"message"
:
"No permission to create Virtual Machine."
},
"create"
:
{
"auth_type"
:
"class"
,
"perms"
:
[
"instance.create_instance"
]},
"retrieve"
:
{
"auth_type"
:
"object"
,
"perms"
:
[
"use_instance"
]},
"destroy"
:
{
"auth_type"
:
"object"
,
"perms"
:
[
"administer_instance"
]},
"template"
:
{
"auth_type"
:
"object"
,
"perms"
:
[
"use_instance"
]},
...
...
@@ -44,7 +44,8 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
def
create
(
self
,
request
):
# TODO: Put this logic in Mixin
if
not
self
.
has_perms_for_model
(
request
.
user
,
'create'
):
return
Response
({
"error"
:
"No permission to create Virtual Machine."
},
status
=
status
.
HTTP_401_UNAUTHORIZED
)
return
Response
({
"error"
:
"No permission to create Virtual Machine."
},
status
=
status
.
HTTP_401_UNAUTHORIZED
)
data
=
request
.
data
template
=
ImageTemplate
.
objects
.
get
(
pk
=
data
[
"template"
])
...
...
@@ -73,7 +74,8 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
def
retrieve
(
self
,
request
,
pk
):
instance
=
self
.
get_object
(
pk
)
if
not
self
.
has_perms_for_object
(
request
.
user
,
'retrieve'
,
instance
):
return
Response
({
"error"
:
"No permission to access the Virtual Machine."
},
status
=
status
.
HTTP_401_UNAUTHORIZED
)
return
Response
({
"error"
:
"No permission to access the Virtual Machine."
},
status
=
status
.
HTTP_401_UNAUTHORIZED
)
instanceDict
=
InstanceSerializer
(
instance
)
.
data
remoteInstance
=
instance
.
get_remote_instance
()
...
...
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