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
255d2160
authored
Mar 17, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
request: add help texts
parent
4db2f63c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
14 deletions
+63
-14
circle/dashboard/templates/dashboard/vm-detail/resources.html
+4
-1
circle/dashboard/views/vm.py
+3
-4
circle/request/forms.py
+22
-6
circle/request/templates/request/_request-template-form.html
+3
-3
circle/request/templates/request/initials/lease.html
+7
-0
circle/request/templates/request/initials/resources.html
+7
-0
circle/request/templates/request/initials/template.html
+7
-0
circle/request/views.py
+10
-0
No files found.
circle/dashboard/templates/dashboard/vm-detail/resources.html
View file @
255d2160
...
...
@@ -22,9 +22,12 @@
</span>
{% else %}
<div
id=
"vm-request-resource-form"
>
<div
class=
"alert alert-info text-justify"
>
{% trans "Changing resources is only possible on virtual machines with STOPPED state. We suggest to turn off the VM after submitting the request otherwise it will be automatically stopped in the future when the request is accepted." %}
</div>
<div
class=
"form-group"
>
<label>
{% trans "Reason" %}*
</label>
<textarea
class=
"form-control"
name=
"reason"
></textarea>
<textarea
class=
"form-control"
name=
"reason"
>
{% include "request/initials/resources.html" %}
</textarea>
</div>
<input
type=
"submit"
class=
"btn btn-success btn-sm"
/>
</div>
...
...
circle/dashboard/views/vm.py
View file @
255d2160
...
...
@@ -67,7 +67,7 @@ from ..forms import (
VmRemoveInterfaceForm
,
)
from
request.models
import
TemplateAccessType
from
request.forms
import
LeaseRequestForm
from
request.forms
import
LeaseRequestForm
,
TemplateRequestForm
from
..models
import
Favourite
from
manager.scheduler
import
has_traits
...
...
@@ -680,7 +680,7 @@ class VmRenewView(FormOperationMixin, TokenOperationView, VmOperationView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
VmRenewView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'lease_request_form'
]
=
LeaseRequestForm
()
context
[
'lease_request_form'
]
=
LeaseRequestForm
(
request
=
self
.
request
)
return
context
...
...
@@ -1047,14 +1047,13 @@ class VmCreate(LoginRequiredMixin, TemplateView):
'template_o'
:
template
,
})
else
:
from
request.forms
import
TemplateRequestForm
context
.
update
({
'template'
:
'dashboard/_vm-create-1.html'
,
'box_title'
:
_
(
'Create a VM'
),
'ajax_title'
:
True
,
'templates'
:
templates
.
all
(),
'template_access_types'
:
TemplateAccessType
.
objects
.
count
(),
'form'
:
TemplateRequestForm
(),
'form'
:
TemplateRequestForm
(
request
=
request
),
})
return
self
.
render_to_response
(
context
)
...
...
circle/request/forms.py
View file @
255d2160
...
...
@@ -19,6 +19,8 @@ from django.forms import (
)
from
django
import
forms
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.template
import
RequestContext
from
django.template.loader
import
render_to_string
from
crispy_forms.helper
import
FormHelper
from
crispy_forms.layout
import
Submit
...
...
@@ -59,19 +61,33 @@ class TemplateAccessTypeForm(ModelForm):
model
=
TemplateAccessType
class
TemplateRequestForm
(
Form
):
class
InitialFromFileMixin
(
object
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
request
=
kwargs
.
pop
(
"request"
,
None
)
super
(
InitialFromFileMixin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
initial
[
'reason'
]
=
render_to_string
(
self
.
initial_template
,
RequestContext
(
request
,
{}),
)
class
TemplateRequestForm
(
InitialFromFileMixin
,
Form
):
template
=
ModelChoiceField
(
TemplateAccessType
.
objects
.
all
(),
label
=
"Template share"
)
label
=
_
(
"Template share"
)
)
level
=
ChoiceField
(
TemplateAccessAction
.
LEVELS
,
widget
=
RadioSelect
,
initial
=
TemplateAccessAction
.
LEVELS
.
user
)
reason
=
CharField
(
widget
=
forms
.
Textarea
)
reason
=
CharField
(
widget
=
forms
.
Textarea
,
label
=
_
(
"Reason"
))
initial_template
=
"request/initials/template.html"
class
LeaseRequestForm
(
Form
):
lease
=
ModelChoiceField
(
LeaseType
.
objects
.
all
(),
label
=
_
(
"Lease"
))
class
LeaseRequestForm
(
InitialFromFileMixin
,
Form
):
lease
=
ModelChoiceField
(
LeaseType
.
objects
.
all
(),
label
=
_
(
"Lease"
))
reason
=
CharField
(
widget
=
forms
.
Textarea
)
initial_template
=
"request/initials/lease.html"
class
ResourceRequestForm
(
VmResourcesForm
):
reason
=
CharField
(
widget
=
forms
.
Textarea
)
circle/request/templates/request/_request-template-form.html
View file @
255d2160
...
...
@@ -6,16 +6,16 @@
{% csrf_token %}
{{ form.template|as_crispy_field }}
<div
style=
"font-weight: bold;"
>
Level
*
</div>
<div
style=
"font-weight: bold;"
>
{% trans "Level" %}
*
</div>
{% for radio in form.level %}
<div
class=
"myradio"
style=
"display: inline-block; padding-left: 20px;"
>
<label>
{{ radio }}
<div
class=
"text-muted"
style=
"padding-left: 16px; font-weight: normal;"
>
{% if forloop.last %}
For users who want to share the template with others.
{% trans "For users who want to share the template with others." %}
{% else %}
For regular users who want to start a virtual machine.
{% trans "For users who want to start a virtual machine." %}
{% endif %}
</div>
</label>
...
...
circle/request/templates/request/initials/lease.html
0 → 100644
View file @
255d2160
{% spaceless %}
{% if LANGUAGE_CODE == "en" %}
Why do you need this lease?
{% else %} {# place your translations here #}
Why do you need this lease?
{% endif %}
{% endspaceless %}
circle/request/templates/request/initials/resources.html
0 → 100644
View file @
255d2160
{% spaceless %}
{% if LANGUAGE_CODE == "en" %}
Why do you need these resources?
{% else %} {# place your translations here #}
Why do you need these resources?
{% endif %}
{% endspaceless %}
circle/request/templates/request/initials/template.html
0 → 100644
View file @
255d2160
{% spaceless %}
{% if LANGUAGE_CODE == "en" %}
Why do you need this template?
{% else %} {# place your translations here #}
Why do you need this template?
{% endif %}
{% endspaceless %}
circle/request/views.py
View file @
255d2160
...
...
@@ -133,6 +133,11 @@ class TemplateRequestView(FormView):
form_class
=
TemplateRequestForm
template_name
=
"request/request-template.html"
def
get_form_kwargs
(
self
):
kwargs
=
super
(
TemplateRequestView
,
self
)
.
get_form_kwargs
()
kwargs
[
'request'
]
=
self
.
request
return
kwargs
def
form_valid
(
self
,
form
):
data
=
form
.
cleaned_data
user
=
self
.
request
.
user
...
...
@@ -174,6 +179,11 @@ class LeaseRequestView(FormView):
context
[
'vm'
]
=
self
.
get_vm
()
return
context
def
get_form_kwargs
(
self
):
kwargs
=
super
(
LeaseRequestView
,
self
)
.
get_form_kwargs
()
kwargs
[
'request'
]
=
self
.
request
return
kwargs
def
form_valid
(
self
,
form
):
data
=
form
.
cleaned_data
user
=
self
.
request
.
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