Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
62dd4060
authored
Feb 11, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webui: Fixed template running instance number
parent
150644d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
11 deletions
+15
-11
one/models.py
+3
-1
one/templates/box-templatelist.html
+2
-2
one/views.py
+10
-8
No files found.
one/models.py
View file @
62dd4060
...
@@ -283,6 +283,8 @@ class Template(models.Model):
...
@@ -283,6 +283,8 @@ class Template(models.Model):
help_text
=
(
_
(
'Name of operating system in format like "
%
s".'
)
%
help_text
=
(
_
(
'Name of operating system in format like "
%
s".'
)
%
"Ubuntu 12.04 LTS Desktop amd64"
))
"Ubuntu 12.04 LTS Desktop amd64"
))
def
running_instances
(
self
):
return
self
.
instance_set
.
exclude
(
state
=
'DONE'
)
.
count
()
def
os_type
(
self
):
def
os_type
(
self
):
if
self
.
access_type
==
'rdp'
:
if
self
.
access_type
==
'rdp'
:
return
"win"
return
"win"
...
@@ -294,7 +296,7 @@ class Template(models.Model):
...
@@ -294,7 +296,7 @@ class Template(models.Model):
@transaction.commit_on_success
@transaction.commit_on_success
def
safe_delete
(
self
):
def
safe_delete
(
self
):
if
not
self
.
instance_set
.
exists
():
if
not
self
.
instance_set
.
ex
clude
(
state
=
'DONE'
)
.
ex
ists
():
self
.
delete
()
self
.
delete
()
return
True
return
True
else
:
else
:
...
...
one/templates/box-templatelist.html
View file @
62dd4060
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
</span></li>
</span></li>
<li
class=
"description"
>
{% trans "Description" %}:
<span
class=
"value"
>
{{t.description}}
</span><div
class=
"clear"
></div></li>
<li
class=
"description"
>
{% trans "Description" %}:
<span
class=
"value"
>
{{t.description}}
</span><div
class=
"clear"
></div></li>
<li
class=
"date"
>
{% trans "Created at" %}:
<span
class=
"value"
>
{{t.created_at}} ({{t.owner.get_profile}})
</span><div
class=
"clear"
></div></li>
<li
class=
"date"
>
{% trans "Created at" %}:
<span
class=
"value"
>
{{t.created_at}} ({{t.owner.get_profile}})
</span><div
class=
"clear"
></div></li>
<li
class=
"count"
>
{% trans "Running instances" %}:
<span
class=
"value"
>
{{
t.instance_set.count
}}
</span></li>
<li
class=
"count"
>
{% trans "Running instances" %}:
<span
class=
"value"
>
{{
t.running_instances
}}
</span></li>
</ul>
</ul>
</div>
</div>
</li>
</li>
...
@@ -72,7 +72,7 @@
...
@@ -72,7 +72,7 @@
</span></li>
</span></li>
<li
class=
"description"
>
{% trans "Description" %}:
<span
class=
"value"
>
{{t.description}}
</span><div
class=
"clear"
></div></li>
<li
class=
"description"
>
{% trans "Description" %}:
<span
class=
"value"
>
{{t.description}}
</span><div
class=
"clear"
></div></li>
<li
class=
"date"
>
{% trans "Created at" %}:
<span
class=
"value"
>
{{t.created_at}} ({{t.owner.get_profile}})
</span><div
class=
"clear"
></div></li>
<li
class=
"date"
>
{% trans "Created at" %}:
<span
class=
"value"
>
{{t.created_at}} ({{t.owner.get_profile}})
</span><div
class=
"clear"
></div></li>
<li
class=
"count"
>
{% trans "Running instances" %}:
<span
class=
"value"
>
{{t.
instance_set.count
}}
</span></li>
<li
class=
"count"
>
{% trans "Running instances" %}:
<span
class=
"value"
>
{{t.
running_instances
}}
</span></li>
</ul>
</ul>
</div>
</div>
</li>
</li>
...
...
one/views.py
View file @
62dd4060
...
@@ -89,15 +89,17 @@ def ajax_template_delete(request):
...
@@ -89,15 +89,17 @@ def ajax_template_delete(request):
except
:
except
:
return
HttpResponse
(
unicode
(
_
(
"Invalid template ID."
)),
status
=
404
)
return
HttpResponse
(
unicode
(
_
(
"Invalid template ID."
)),
status
=
404
)
template
=
get_object_or_404
(
Template
,
id
=
template_id
)
template
=
get_object_or_404
(
Template
,
id
=
template_id
)
if
template
.
instance_set
.
exists
()
:
if
template
.
running_instances
()
>
0
:
return
HttpResponse
(
unicode
(
_
(
"There are running instances of this template."
)),
status
=
404
)
return
HttpResponse
(
unicode
(
_
(
"There are running instances of this template."
)),
status
=
404
)
elif
template
.
share_set
.
exists
():
elif
template
.
share_set
.
exists
():
return
HttpResponse
(
unicode
(
_
(
"Template is still shared."
)),
status
=
404
)
return
HttpResponse
(
unicode
(
_
(
"Template is still shared."
)),
status
=
404
)
elif
template
.
owner
!=
request
.
user
:
elif
template
.
owner
!=
request
.
user
:
return
HttpResponse
(
unicode
(
_
(
"You don't have permission to delete this template."
)),
status
=
404
)
return
HttpResponse
(
unicode
(
_
(
"You don't have permission to delete this template."
)),
status
=
404
)
else
:
else
:
template
.
safe_delete
()
if
template
.
safe_delete
():
return
HttpResponse
(
unicode
(
_
(
"Template successfully deleted."
)))
return
HttpResponse
(
unicode
(
_
(
"Template successfully deleted."
)))
else
:
return
HttpResponse
(
unicode
(
_
(
"Unexpected error happened."
)),
status
=
404
)
def
ajax_template_name_unique
(
request
,
name
):
def
ajax_template_name_unique
(
request
,
name
):
s
=
"True"
s
=
"True"
...
@@ -107,12 +109,12 @@ def ajax_template_name_unique(request, name):
...
@@ -107,12 +109,12 @@ def ajax_template_name_unique(request, name):
@login_required
@login_required
def
vm_credentials
(
request
,
iid
):
def
vm_credentials
(
request
,
iid
):
vm
=
get_object_or_404
(
Instance
,
pk
=
iid
)
try
:
if
vm
.
owner
==
request
.
user
:
vm
=
get_object_or_404
(
Instance
,
pk
=
iid
,
owner
=
request
.
user
)
return
render_to_response
(
'vm-credentials.html'
,
RequestContext
(
request
,
{
'i'
:
vm
}))
return
render_to_response
(
'vm-credentials.html'
,
RequestContext
(
request
,
{
'i'
:
vm
}))
e
lse
:
e
xcept
:
return
HttpResponse
(
"Stale id."
)
return
HttpResponse
(
_
(
"Could not get Virtual Machine credentials."
),
code
=
404
)
messages
.
error
(
request
,
_
(
'Failed to power off virtual machine.'
))
class
AjaxTemplateWizard
(
View
):
class
AjaxTemplateWizard
(
View
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
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