Added CBVs for Manufacturers

This commit is contained in:
Jeremy Stretch
2016-05-13 15:22:31 -04:00
parent 558fb60c50
commit 4eeae08fb5
8 changed files with 139 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
import django_tables2 as tables
from django_tables2.utils import Accessor
from .models import Site, RackGroup, Rack, DeviceType, ConsolePortTemplate, ConsoleServerPortTemplate, \
from .models import Site, RackGroup, Rack, Manufacturer, DeviceType, ConsolePortTemplate, ConsoleServerPortTemplate,\
PowerPortTemplate, PowerOutletTemplate, InterfaceTemplate, DeviceRole, Device, ConsolePort, PowerPort
DEVICE_LINK = """
@@ -16,6 +16,10 @@ DEVICEROLE_EDIT_LINK = """
{% if perms.dcim.change_devicerole %}<a href="{% url 'dcim:devicerole_edit' slug=record.slug %}">Edit</a>{% endif %}
"""
MANUFACTURER_EDIT_LINK = """
{% if perms.dcim.change_manufacturer %}<a href="{% url 'dcim:manufacturer_edit' slug=record.slug %}">Edit</a>{% endif %}
"""
STATUS_ICON = """
<span class="glyphicon glyphicon-{% if record.status %}ok-sign text-success" title="Active{% else %}minus-sign text-danger" title="Offline{% endif %}" aria-hidden="true"></span>
"""
@@ -87,6 +91,26 @@ class RackTable(tables.Table):
}
#
# Manufacturers
#
class ManufacturerTable(tables.Table):
pk = tables.CheckBoxColumn(visible=False, default='')
name = tables.LinkColumn(verbose_name='Name')
devicetype_count = tables.Column(verbose_name='Device Types')
slug = tables.Column(verbose_name='Slug')
edit = tables.TemplateColumn(template_code=MANUFACTURER_EDIT_LINK, verbose_name='')
class Meta:
model = Manufacturer
fields = ('pk', 'name', 'devicetype_count', 'slug', 'edit')
empty_text = "No device types were found."
attrs = {
'class': 'table table-hover',
}
#
# Device types
#