Added front-end UI for RackGroups

This commit is contained in:
Jeremy Stretch
2016-03-30 12:26:37 -04:00
parent 87fffce7ea
commit 2f86d5e43d
10 changed files with 265 additions and 76 deletions

View File

@@ -1,27 +1,17 @@
import django_tables2 as tables
from django_tables2.utils import Accessor
from .models import Site, Rack, DeviceType, ConsolePortTemplate, ConsoleServerPortTemplate, PowerPortTemplate, \
PowerOutletTemplate, InterfaceTemplate, Device, ConsolePort, PowerPort
PREFIXES_PER_VLAN = """
{% for p in record.prefix_set.all %}
<a href="{% url 'ipam:prefix' pk=p.pk %}">{{ p }}</a>
{% if not forloop.last %}<br />{% endif %}
{% endfor %}
"""
STATUS_LABEL = """
<span class="label label-{{ record.status.get_bootstrap_class_display|lower }}">
{{ record.status.name }}
</span>
"""
from .models import Site, RackGroup, Rack, DeviceType, ConsolePortTemplate, ConsoleServerPortTemplate, \
PowerPortTemplate, PowerOutletTemplate, InterfaceTemplate, Device, ConsolePort, PowerPort
DEVICE_LINK = """
<a href="{% url 'dcim:device' pk=record.pk %}">{{ record.name|default:'<span class="label label-info">Unnamed device</span>' }}</a>
"""
RACKGROUP_EDIT_LINK = """
<a href="{% url 'dcim:rackgroup_edit' pk=record.pk %}">Edit</a>
"""
#
# Sites
@@ -46,6 +36,33 @@ class SiteTable(tables.Table):
}
#
# Rack groups
#
class RackGroupTable(tables.Table):
name = tables.LinkColumn(verbose_name='Name')
site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')], verbose_name='Site')
slug = tables.Column(verbose_name='Slug')
class Meta:
model = RackGroup
fields = ('name', 'site', 'slug')
empty_text = "No rack groups were found."
attrs = {
'class': 'table table-hover',
}
class RackGroupBulkEditTable(RackGroupTable):
pk = tables.CheckBoxColumn()
edit = tables.TemplateColumn(template_code=RACKGROUP_EDIT_LINK, verbose_name='')
class Meta(RackGroupTable.Meta):
model = None # django_tables2 bugfix
fields = ('pk', 'name', 'site', 'slug', 'edit')
#
# Racks
#