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
631b1909
authored
Feb 06, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add disks to storage
parent
51d0dbc9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
9 deletions
+69
-9
circle/dashboard/forms.py
+12
-1
circle/dashboard/tables.py
+6
-2
circle/dashboard/templates/dashboard/base.html
+5
-0
circle/dashboard/templates/dashboard/storage/disk.html
+33
-0
circle/dashboard/urls.py
+3
-1
circle/dashboard/views/storage.py
+10
-5
No files found.
circle/dashboard/forms.py
View file @
631b1909
...
...
@@ -54,7 +54,7 @@ from firewall.models import Vlan, Host
from
vm.models
import
(
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
,
Instance
)
from
storage.models
import
DataStore
from
storage.models
import
DataStore
,
Disk
from
django.contrib.admin.widgets
import
FilteredSelectMultiple
from
django.contrib.auth.models
import
Permission
from
.models
import
Profile
,
GroupProfile
...
...
@@ -1523,3 +1523,14 @@ class DataStoreForm(ModelForm):
class
Meta
:
model
=
DataStore
class
DiskForm
(
ModelForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
DiskForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
for
k
,
v
in
self
.
fields
.
iteritems
():
v
.
widget
.
attrs
[
'readonly'
]
=
True
class
Meta
:
model
=
Disk
circle/dashboard/tables.py
View file @
631b1909
...
...
@@ -22,7 +22,6 @@ 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
...
...
@@ -55,6 +54,7 @@ class ApplianceColumn(TemplateColumn):
title
,
text
=
ugettext
(
"Virtual machine"
),
ugettext
(
"[VM]"
)
return
mark_safe
(
"
%
s
%
s"
%
(
abbr
%
(
title
,
text
),
value
))
class
NodeListTable
(
Table
):
pk
=
Column
(
...
...
@@ -322,7 +322,11 @@ class ConnectCommandListTable(Table):
class
DiskListTable
(
Table
):
pk
=
LinkColumn
(
'dashboard.views.disk-detail'
,
args
=
[
A
(
'pk'
)],
verbose_name
=
_
(
"ID"
),
)
size
=
FileSizeColumn
()
appliance
=
ApplianceColumn
(
template_name
=
"dashboard/storage/column-appliance.html"
,
...
...
circle/dashboard/templates/dashboard/base.html
View file @
631b1909
...
...
@@ -24,6 +24,11 @@
<a
href=
"/admin/"
><i
class=
"fa fa-cogs"
></i>
{% trans "Admin" %}
</a>
</li>
<li>
<a
href=
"{% url "
dashboard
.
views
.
storage
"
%}"
><i
class=
"fa fa-database"
></i>
{% trans "Storage" %}
</a>
</li>
<li>
<a
href=
"/network/"
><i
class=
"fa fa-globe"
></i>
{% trans "Network" %}
</a>
</li>
{% endif %}
...
...
circle/dashboard/templates/dashboard/storage/disk.html
0 → 100644
View file @
631b1909
{% extends "dashboard/base.html" %}
{% load staticfiles %}
{% load i18n %}
{% load render_table from django_tables2 %}
{% load crispy_forms_tags %}
{% block title-page %}{% trans "Disk" %} | {% trans "Storage" %}{% endblock %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<div
class=
"pull-right"
>
{% with app=object.get_appliance %}
{% if app %}
{% trans "Appliance" %}:
<a
href=
"{{ app.get_absolute_url }}"
>
{{ app.name }}
</a>
{% else %}
This disk is not attached to anything.
{% endif %}
{% endwith %}
</div>
<h3
class=
"no-margin"
><i
class=
"fa fa-file"
></i>
{% trans "Disk" %}
</h3>
</div>
<div
class=
"panel-body"
>
{% crispy form %}
</div>
<!-- .panel-body -->
</div>
</div>
</div>
{% endblock %}
circle/dashboard/urls.py
View file @
631b1909
...
...
@@ -52,7 +52,7 @@ from .views import (
TransferTemplateOwnershipView
,
TransferTemplateOwnershipConfirmView
,
OpenSearchDescriptionView
,
NodeActivityView
,
StorageDetail
,
StorageDetail
,
DiskDetail
,
)
from
.views.vm
import
vm_ops
,
vm_mass_ops
from
.views.node
import
node_ops
...
...
@@ -228,6 +228,8 @@ urlpatterns = patterns(
url
(
r'^storage/$'
,
StorageDetail
.
as_view
(),
name
=
"dashboard.views.storage"
),
url
(
r'^disk/(?P<pk>\d+)/$'
,
DiskDetail
.
as_view
(),
name
=
"dashboard.views.disk-detail"
),
)
urlpatterns
+=
patterns
(
...
...
circle/dashboard/views/storage.py
View file @
631b1909
...
...
@@ -17,19 +17,18 @@
from
__future__
import
unicode_literals
,
absolute_import
from
django.views.generic
import
(
UpdateView
)
from
django.views.generic
import
UpdateView
from
django.core.urlresolvers
import
reverse
from
sizefield.utils
import
filesizeformat
from
braces.views
import
SuperuserRequiredMixin
from
storage.models
import
DataStore
,
Disk
from
..tables
import
DiskListTable
from
..forms
import
DataStoreForm
from
..forms
import
DataStoreForm
,
DiskForm
class
StorageDetail
(
UpdateView
):
class
StorageDetail
(
SuperuserRequiredMixin
,
UpdateView
):
model
=
DataStore
form_class
=
DataStoreForm
template_name
=
"dashboard/storage/detail.html"
...
...
@@ -67,3 +66,9 @@ class StorageDetail(UpdateView):
def
get_success_url
(
self
):
return
reverse
(
"dashboard.views.storage"
)
class
DiskDetail
(
SuperuserRequiredMixin
,
UpdateView
):
model
=
Disk
form_class
=
DiskForm
template_name
=
"dashboard/storage/disk.html"
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