Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
842cdcc6
authored
Mar 11, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
request: save lease request
parent
30dd7df4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
circle/request/views.py
+28
-5
No files found.
circle/request/views.py
View file @
842cdcc6
...
...
@@ -11,7 +11,7 @@ from django_tables2 import SingleTableView
from
request.models
import
(
Request
,
TemplateAccessType
,
LeaseType
,
TemplateAccessAction
,
#
ExtendLeaseAction,
ExtendLeaseAction
,
)
from
vm.models
import
Instance
from
request.tables
import
(
...
...
@@ -118,15 +118,38 @@ class LeaseRequestView(FormView):
form_class
=
LeaseRequestForm
template_name
=
"request/request-lease.html"
def
get_context_data
(
self
,
**
kwargs
):
vm
=
get_object_or_404
(
Instance
,
pk
=
self
.
kwargs
[
'vm_pk'
])
def
get_vm
(
self
):
return
get_object_or_404
(
Instance
,
pk
=
self
.
kwargs
[
'vm_pk'
])
def
dispatch
(
self
,
*
args
,
**
kwargs
):
vm
=
self
.
get_vm
()
user
=
self
.
request
.
user
if
not
vm
.
has_level
(
user
,
'operator'
):
raise
PermissionDenied
()
return
super
(
LeaseRequestView
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
LeaseRequestView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'vm'
]
=
vm
context
[
'vm'
]
=
self
.
get_vm
()
return
context
def
form_valid
(
self
,
form
):
pass
data
=
form
.
cleaned_data
user
=
self
.
request
.
user
vm
=
self
.
get_vm
()
el
=
ExtendLeaseAction
(
lease_type
=
data
[
'lease'
],
instance
=
vm
,
)
el
.
save
()
req
=
Request
(
user
=
user
,
reason
=
data
[
'reason'
],
type
=
Request
.
TYPES
.
lease
,
action
=
el
)
req
.
save
()
return
redirect
(
vm
.
get_absolute_url
())
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