Commit db8ae8b0 by Oláh István Gergely

dashboard: create add trait in NodeDetail, fix traits list

parent e12f401e
......@@ -10,8 +10,8 @@
<div style="font-weight: bold;">{% trans "Traits" %}</div>
<div id="node-details-traits" style="margin-bottom: 20px;">
<div id="node-details-traits-list">
{% if node.tags.all %}
{% for t in node.tags.all %}
{% if node.traits.all %}
{% for t in node.traits.all %}
<div class="label label-primary label-tag" style="display: inline-block">
{{ t }}
<a href="#" class="node-details-remove-trait"><i class="icon-remove"></i></a>
......@@ -34,7 +34,7 @@ from .tables import (VmListTable, NodeListTable, NodeVmListTable,
TemplateListTable, LeaseListTable, GroupListTable,)
from vm.models import (Instance, InstanceTemplate, InterfaceTemplate,
InstanceActivity, Node, instance_activity, Lease,
Interface, NodeActivity, Trait)
from firewall.models import Vlan, Host, Rule
from storage.models import Disk
from dashboard.models import Favourite
......@@ -444,6 +444,10 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
context = super(NodeDetailView, self).get_context_data(**kwargs)
instances =
context['table'] = NodeVmListTable(instances)
ia = NodeActivity.objects.filter(
node=self.object, parent=None
context['activities'] = ia
return context
def post(self, request, *args, **kwargs):
......@@ -451,6 +455,8 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
return self.__set_name(request)
if request.POST.get('new_status'):
return self.__set_status(request)
if request.POST.get('new_trait'):
return self.__add_trait(request)
def __set_name(self, request):
self.object = self.get_object()
......@@ -500,6 +506,25 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
return redirect(reverse_lazy("dashboard.views.node-detail",
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!"
messages.error(request, message)
return redirect(reverse_lazy("dashboard.views.node-detail",
class GroupDetailView(CheckedDetailView):
template_name = "dashboard/group-detail.html"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment