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
db8ae8b0
authored
Feb 17, 2014
by
Oláh István Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: create add trait in NodeDetail, fix traits list
parent
e12f401e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
circle/dashboard/templates/dashboard/node-detail-home.html
+2
-2
circle/dashboard/views.py
+26
-1
No files found.
circle/dashboard/templates/dashboard/node-detail-home.html
View file @
db8ae8b0
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
<div
style=
"font-weight: bold;"
>
{% trans "Traits" %}
</div>
<div
style=
"font-weight: bold;"
>
{% trans "Traits" %}
</div>
<div
id=
"node-details-traits"
style=
"margin-bottom: 20px;"
>
<div
id=
"node-details-traits"
style=
"margin-bottom: 20px;"
>
<div
id=
"node-details-traits-list"
>
<div
id=
"node-details-traits-list"
>
{% if node.t
ag
s.all %}
{% if node.t
rait
s.all %}
{% for t in node.t
ag
s.all %}
{% for t in node.t
rait
s.all %}
<div
class=
"label label-primary label-tag"
style=
"display: inline-block"
>
<div
class=
"label label-primary label-tag"
style=
"display: inline-block"
>
{{ t }}
{{ t }}
<a
href=
"#"
class=
"node-details-remove-trait"
><i
class=
"icon-remove"
></i></a>
<a
href=
"#"
class=
"node-details-remove-trait"
><i
class=
"icon-remove"
></i></a>
...
...
circle/dashboard/views.py
View file @
db8ae8b0
...
@@ -34,7 +34,7 @@ from .tables import (VmListTable, NodeListTable, NodeVmListTable,
...
@@ -34,7 +34,7 @@ from .tables import (VmListTable, NodeListTable, NodeVmListTable,
TemplateListTable
,
LeaseListTable
,
GroupListTable
,)
TemplateListTable
,
LeaseListTable
,
GroupListTable
,)
from
vm.models
import
(
Instance
,
InstanceTemplate
,
InterfaceTemplate
,
from
vm.models
import
(
Instance
,
InstanceTemplate
,
InterfaceTemplate
,
InstanceActivity
,
Node
,
instance_activity
,
Lease
,
InstanceActivity
,
Node
,
instance_activity
,
Lease
,
Interface
)
Interface
,
NodeActivity
,
Trait
)
from
firewall.models
import
Vlan
,
Host
,
Rule
from
firewall.models
import
Vlan
,
Host
,
Rule
from
storage.models
import
Disk
from
storage.models
import
Disk
from
dashboard.models
import
Favourite
from
dashboard.models
import
Favourite
...
@@ -444,6 +444,10 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
...
@@ -444,6 +444,10 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
context
=
super
(
NodeDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
NodeDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
instances
=
Instance
.
active
.
filter
(
node
=
self
.
object
)
instances
=
Instance
.
active
.
filter
(
node
=
self
.
object
)
context
[
'table'
]
=
NodeVmListTable
(
instances
)
context
[
'table'
]
=
NodeVmListTable
(
instances
)
ia
=
NodeActivity
.
objects
.
filter
(
node
=
self
.
object
,
parent
=
None
)
.
order_by
(
'-started'
)
.
select_related
()
context
[
'activities'
]
=
ia
return
context
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
...
@@ -451,6 +455,8 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
...
@@ -451,6 +455,8 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
return
self
.
__set_name
(
request
)
return
self
.
__set_name
(
request
)
if
request
.
POST
.
get
(
'new_status'
):
if
request
.
POST
.
get
(
'new_status'
):
return
self
.
__set_status
(
request
)
return
self
.
__set_status
(
request
)
if
request
.
POST
.
get
(
'new_trait'
):
return
self
.
__add_trait
(
request
)
def
__set_name
(
self
,
request
):
def
__set_name
(
self
,
request
):
self
.
object
=
self
.
get_object
()
self
.
object
=
self
.
get_object
()
...
@@ -500,6 +506,25 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
...
@@ -500,6 +506,25 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
return
redirect
(
reverse_lazy
(
"dashboard.views.node-detail"
,
return
redirect
(
reverse_lazy
(
"dashboard.views.node-detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
def
__add_trait
(
self
,
request
):
new_trait_name
=
request
.
POST
.
get
(
'new_trait'
)
self
.
object
=
self
.
get_object
()
if
len
(
new_trait_name
)
<
1
:
message
=
u"Please input something!"
elif
len
(
new_trait_name
)
>
20
:
message
=
u"Trait name is too long!"
else
:
self
.
object
.
traits
.
create
(
name
=
new_trait_name
)
try
:
messages
.
error
(
request
,
message
)
except
:
pass
return
redirect
(
reverse_lazy
(
"dashboard.views.node-detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
class
GroupDetailView
(
CheckedDetailView
):
class
GroupDetailView
(
CheckedDetailView
):
template_name
=
"dashboard/group-detail.html"
template_name
=
"dashboard/group-detail.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