Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
36231e8f
authored
Mar 18, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
request: fix trivial mistakes
parent
255d2160
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
30 deletions
+38
-30
circle/dashboard/views/vm.py
+1
-1
circle/request/forms.py
+0
-3
circle/request/migrations/0003_auto_20150318_1023.py
+20
-0
circle/request/models.py
+1
-1
circle/request/views.py
+16
-25
No files found.
circle/dashboard/views/vm.py
View file @
36231e8f
...
...
@@ -1052,7 +1052,7 @@ class VmCreate(LoginRequiredMixin, TemplateView):
'box_title'
:
_
(
'Create a VM'
),
'ajax_title'
:
True
,
'templates'
:
templates
.
all
(),
'template_access_types'
:
TemplateAccessType
.
objects
.
count
(),
'template_access_types'
:
TemplateAccessType
.
objects
.
exists
(),
'form'
:
TemplateRequestForm
(
request
=
request
),
})
return
self
.
render_to_response
(
context
)
...
...
circle/request/forms.py
View file @
36231e8f
...
...
@@ -32,9 +32,6 @@ from dashboard.forms import VmResourcesForm
class
LeaseTypeForm
(
ModelForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
LeaseTypeForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
@property
def
helper
(
self
):
helper
=
FormHelper
()
...
...
circle/request/migrations/0003_auto_20150318_1023.py
0 → 100644
View file @
36231e8f
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'request'
,
'0002_auto_20150317_1211'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'request'
,
name
=
'reason'
,
field
=
models
.
TextField
(
verbose_name
=
'Reason'
),
preserve_default
=
True
,
),
]
circle/request/models.py
View file @
36231e8f
...
...
@@ -66,7 +66,7 @@ class Request(TimeStampedModel):
(
'template'
,
_
(
"template access"
)),
)
type
=
CharField
(
choices
=
TYPES
,
max_length
=
10
)
reason
=
TextField
(
help_text
=
"szia"
)
reason
=
TextField
(
verbose_name
=
_
(
"Reason"
)
)
content_type
=
ForeignKey
(
ContentType
)
object_id
=
IntegerField
()
...
...
circle/request/views.py
View file @
36231e8f
...
...
@@ -160,31 +160,37 @@ class TemplateRequestView(FormView):
return
redirect
(
"/"
)
class
LeaseRequestView
(
FormView
):
form_class
=
LeaseRequestForm
template_name
=
"request/request-lease.html"
class
VmRequestMixin
(
object
):
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'
):
if
not
vm
.
has_level
(
user
,
self
.
user_level
):
raise
PermissionDenied
()
return
super
(
LeaseRequestView
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
return
super
(
VmRequestMixin
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
LeaseRequestView
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
VmRequestMixin
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'vm'
]
=
self
.
get_vm
()
return
context
def
get_form_kwargs
(
self
):
kwargs
=
super
(
LeaseRequestView
,
self
)
.
get_form_kwargs
()
kwargs
=
super
(
VmRequestMixin
,
self
)
.
get_form_kwargs
()
kwargs
[
'request'
]
=
self
.
request
return
kwargs
def
form_valid
(
self
,
form
):
raise
NotImplementedError
class
LeaseRequestView
(
VmRequestMixin
,
FormView
):
form_class
=
LeaseRequestForm
template_name
=
"request/request-lease.html"
user_level
=
"operator"
def
form_valid
(
self
,
form
):
data
=
form
.
cleaned_data
user
=
self
.
request
.
user
vm
=
self
.
get_vm
()
...
...
@@ -206,29 +212,14 @@ class LeaseRequestView(FormView):
return
redirect
(
vm
.
get_absolute_url
())
class
ResourceRequestView
(
FormView
):
class
ResourceRequestView
(
VmRequestMixin
,
FormView
):
form_class
=
ResourceRequestForm
template_name
=
"request/request-resource.html"
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
,
"user"
):
raise
PermissionDenied
()
return
super
(
ResourceRequestView
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ResourceRequestView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'vm'
]
=
self
.
get_vm
()
return
context
user_level
=
"user"
def
get_form_kwargs
(
self
):
kwargs
=
super
(
ResourceRequestView
,
self
)
.
get_form_kwargs
()
kwargs
[
'can_edit'
]
=
True
kwargs
[
'instance'
]
=
self
.
get_vm
()
return
kwargs
def
get_initial
(
self
):
...
...
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