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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
51d0dbc9
authored
Feb 06, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: appliance columns for disk list
parent
2faa9566
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
+42
-5
circle/dashboard/tables.py
+28
-2
circle/dashboard/templates/dashboard/storage/column-appliance.html
+9
-0
circle/storage/models.py
+5
-3
No files found.
circle/dashboard/tables.py
View file @
51d0dbc9
...
...
@@ -21,10 +21,12 @@ from django.contrib.auth.models import Group, User
from
django_tables2
import
Table
,
A
from
django_tables2.columns
import
(
TemplateColumn
,
Column
,
LinkColumn
,
BooleanColumn
)
from
django.utils.safestring
import
mark_safe
from
django.utils.html
import
escape
from
vm.models
import
Node
,
InstanceTemplate
,
Lease
from
storage.models
import
Disk
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext
from
django_sshkey.models
import
UserKey
from
dashboard.models
import
ConnectCommand
...
...
@@ -37,6 +39,22 @@ class FileSizeColumn(Column):
return
size
class
ApplianceColumn
(
TemplateColumn
):
def
render
(
self
,
*
args
,
**
kwargs
):
value
=
super
(
ApplianceColumn
,
self
)
.
render
(
*
args
,
**
kwargs
)
abbr
=
'<abbr title="
%
s">
%
s</abbr>'
appliance
=
kwargs
[
'record'
]
.
get_appliance
()
if
appliance
is
None
:
return
value
elif
isinstance
(
appliance
,
InstanceTemplate
):
# Translators: [T] as Template
title
,
text
=
ugettext
(
"Template"
),
ugettext
(
"[T]"
)
else
:
# Translators: [VM] as Virtual Machine
title
,
text
=
ugettext
(
"Virtual machine"
),
ugettext
(
"[VM]"
)
return
mark_safe
(
"
%
s
%
s"
%
(
abbr
%
(
title
,
text
),
value
))
class
NodeListTable
(
Table
):
pk
=
Column
(
...
...
@@ -306,12 +324,20 @@ class ConnectCommandListTable(Table):
class
DiskListTable
(
Table
):
size
=
FileSizeColumn
()
appliance
=
ApplianceColumn
(
template_name
=
"dashboard/storage/column-appliance.html"
,
verbose_name
=
_
(
"Appliance"
),
orderable
=
False
,
)
is_ready
=
BooleanColumn
(
verbose_name
=
_
(
"ready"
)
)
class
Meta
:
model
=
Disk
attrs
=
{
'class'
:
"table table-bordered table-striped table-hover"
,
'id'
:
"disk-list-table"
}
fields
=
(
"pk"
,
"
nam
e"
,
"filename"
,
"size"
,
"is_ready"
)
fields
=
(
"pk"
,
"
applianc
e"
,
"filename"
,
"size"
,
"is_ready"
)
prefix
=
"disk-"
order_by
=
(
"-pk"
,
)
per_page
=
65536
circle/dashboard/templates/dashboard/storage/column-appliance.html
0 → 100644
View file @
51d0dbc9
{% load i18n %}
{% with app=record.get_appliance %}
{% if app %}
<a
href=
"{{ app.get_absolute_url }}"
>
{{ app.name }}
</a>
{% else %}
—
{% endif %}
{% endwith %}
circle/storage/models.py
View file @
51d0dbc9
...
...
@@ -27,6 +27,7 @@ import re
from
celery.contrib.abortable
import
AbortableAsyncResult
from
django.db.models
import
(
Model
,
BooleanField
,
CharField
,
DateTimeField
,
ForeignKey
)
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
model_utils.models
import
TimeStampedModel
...
...
@@ -290,9 +291,10 @@ class Disk(TimeStampedModel):
"""
from
vm.models
import
Instance
try
:
return
self
.
instance_set
.
get
()
except
Instance
.
DoesNotExist
:
return
self
.
template_set
.
get
()
app
=
self
.
template_set
.
all
()
or
self
.
instance_set
.
all
()
return
app
.
get
()
except
ObjectDoesNotExist
:
return
None
def
get_exclusive
(
self
):
"""Get an instance of the disk for exclusive usage.
...
...
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