Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0dddcecb
authored
Jul 29, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: humanize operations' exceptions
parent
7156a8be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
circle/vm/operations.py
+9
-5
No files found.
circle/vm/operations.py
View file @
0dddcecb
...
@@ -26,7 +26,7 @@ from django.utils.translation import ugettext_lazy as _, ugettext_noop
...
@@ -26,7 +26,7 @@ from django.utils.translation import ugettext_lazy as _, ugettext_noop
from
celery.exceptions
import
TimeLimitExceeded
from
celery.exceptions
import
TimeLimitExceeded
from
common.models
import
create_readable
from
common.models
import
create_readable
,
humanize_exception
from
common.operations
import
Operation
,
register_operation
from
common.operations
import
Operation
,
register_operation
from
.tasks.local_tasks
import
(
from
.tasks.local_tasks
import
(
abortable_async_instance_operation
,
abortable_async_node_operation
,
abortable_async_instance_operation
,
abortable_async_node_operation
,
...
@@ -56,8 +56,9 @@ class InstanceOperation(Operation):
...
@@ -56,8 +56,9 @@ class InstanceOperation(Operation):
def
check_auth
(
self
,
user
):
def
check_auth
(
self
,
user
):
if
not
self
.
instance
.
has_level
(
user
,
self
.
acl_level
):
if
not
self
.
instance
.
has_level
(
user
,
self
.
acl_level
):
raise
PermissionDenied
(
"
%
s doesn't have the required ACL level."
%
raise
humanize_exception
(
ugettext_noop
(
user
)
"
%(acl_level)
s level is required for this operation."
),
PermissionDenied
(),
acl_level
=
self
.
acl_level
)
super
(
InstanceOperation
,
self
)
.
check_auth
(
user
=
user
)
super
(
InstanceOperation
,
self
)
.
check_auth
(
user
=
user
)
...
@@ -109,7 +110,9 @@ class AddInterfaceOperation(InstanceOperation):
...
@@ -109,7 +110,9 @@ class AddInterfaceOperation(InstanceOperation):
def
_operation
(
self
,
activity
,
user
,
system
,
vlan
,
managed
=
None
):
def
_operation
(
self
,
activity
,
user
,
system
,
vlan
,
managed
=
None
):
if
not
vlan
.
has_level
(
user
,
'user'
):
if
not
vlan
.
has_level
(
user
,
'user'
):
raise
PermissionDenied
()
raise
humanize_exception
(
ugettext_noop
(
"User acces to vlan
%(vlan)
s is required."
),
PermissionDenied
(),
vlan
=
vlan
)
if
managed
is
None
:
if
managed
is
None
:
managed
=
vlan
.
managed
managed
=
vlan
.
managed
...
@@ -790,7 +793,8 @@ class FlushOperation(NodeOperation):
...
@@ -790,7 +793,8 @@ class FlushOperation(NodeOperation):
def
check_auth
(
self
,
user
):
def
check_auth
(
self
,
user
):
if
not
user
.
is_superuser
:
if
not
user
.
is_superuser
:
raise
PermissionDenied
()
raise
humanize_exception
(
ugettext_noop
(
"Superuser privileges are required."
),
PermissionDenied
())
super
(
FlushOperation
,
self
)
.
check_auth
(
user
=
user
)
super
(
FlushOperation
,
self
)
.
check_auth
(
user
=
user
)
...
...
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