Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
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
Commit
a09339a2
authored
Sep 08, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-279' into 'master'
Issue #279
parents
c90bf692
a5106f3d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
circle/dashboard/views.py
+20
-17
No files found.
circle/dashboard/views.py
View file @
a09339a2
...
@@ -2121,23 +2121,29 @@ class VmCreate(LoginRequiredMixin, TemplateView):
...
@@ -2121,23 +2121,29 @@ class VmCreate(LoginRequiredMixin, TemplateView):
if
not
request
.
user
.
has_perm
(
'vm.create_vm'
):
if
not
request
.
user
.
has_perm
(
'vm.create_vm'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
form_error
=
form
is
not
None
if
form
is
None
:
template
=
(
form
.
template
.
pk
if
form_error
template_pk
=
request
.
GET
.
get
(
"template"
)
else
request
.
GET
.
get
(
"template"
))
else
:
templates
=
InstanceTemplate
.
get_objects_with_level
(
template_pk
=
form
.
template
.
pk
'user'
,
request
.
user
,
disregard_superuser
=
True
)
if
form
is
None
and
template
:
if
template_pk
:
form
=
self
.
form_class
(
user
=
request
.
user
,
template
=
get_object_or_404
(
InstanceTemplate
,
pk
=
template_pk
)
template
=
templates
.
get
(
pk
=
template
))
if
not
template
.
has_level
(
request
.
user
,
'user'
):
raise
PermissionDenied
()
if
form
is
None
:
form
=
self
.
form_class
(
user
=
request
.
user
,
template
=
template
)
else
:
templates
=
InstanceTemplate
.
get_objects_with_level
(
'user'
,
request
.
user
,
disregard_superuser
=
True
)
context
=
self
.
get_context_data
(
**
kwargs
)
context
=
self
.
get_context_data
(
**
kwargs
)
if
template
:
if
template
_pk
:
context
.
update
({
context
.
update
({
'template'
:
'dashboard/_vm-create-2.html'
,
'template'
:
'dashboard/_vm-create-2.html'
,
'box_title'
:
_
(
'Customize VM'
),
'box_title'
:
_
(
'Customize VM'
),
'ajax_title'
:
True
,
'ajax_title'
:
True
,
'vm_create_form'
:
form
,
'vm_create_form'
:
form
,
'template_o'
:
template
s
.
get
(
pk
=
template
)
,
'template_o'
:
template
,
})
})
else
:
else
:
context
.
update
({
context
.
update
({
...
@@ -2163,18 +2169,15 @@ class VmCreate(LoginRequiredMixin, TemplateView):
...
@@ -2163,18 +2169,15 @@ class VmCreate(LoginRequiredMixin, TemplateView):
def
__create_customized
(
self
,
request
,
*
args
,
**
kwargs
):
def
__create_customized
(
self
,
request
,
*
args
,
**
kwargs
):
user
=
request
.
user
user
=
request
.
user
# no form yet, using POST directly:
template
=
get_object_or_404
(
InstanceTemplate
,
pk
=
request
.
POST
.
get
(
"template"
))
form
=
self
.
form_class
(
form
=
self
.
form_class
(
request
.
POST
,
user
=
request
.
user
,
request
.
POST
,
user
=
request
.
user
,
template
=
template
)
template
=
InstanceTemplate
.
objects
.
get
(
pk
=
request
.
POST
.
get
(
"template"
)
)
)
if
not
form
.
is_valid
():
if
not
form
.
is_valid
():
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
post
=
form
.
cleaned_data
post
=
form
.
cleaned_data
template
=
InstanceTemplate
.
objects
.
get
(
pk
=
post
[
'template'
])
# permission check
if
not
template
.
has_level
(
user
,
'user'
):
if
not
template
.
has_level
(
user
,
'user'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
...
...
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