Commit ec0e901c by Őry Máté

network: add MACColumn

parent 521aa877
......@@ -15,14 +15,30 @@
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <>.
from netaddr import EUI
from django.utils.translation import ugettext_lazy as _
from django.utils.html import format_html
from django_tables2 import Table, A
from django_tables2.columns import LinkColumn, TemplateColumn
from django_tables2.columns import LinkColumn, TemplateColumn, Column
from firewall.models import Host, Vlan, Domain, Group, Record, Rule, SwitchPort
class MACColumn(Column):
def render(self, value):
if isinstance(value, basestring):
value = EUI(value)
return value
return format_html('<abbr title="{0}">{1}</abbr>',
value.oui.registration().org, value)
return value
class BlacklistItemTable(Table):
ipv4 = LinkColumn('network.blacklist', args=[A('pk')])
......@@ -55,9 +71,7 @@ class GroupTable(Table):
class HostTable(Table):
hostname = LinkColumn('', args=[A('pk')])
mac = TemplateColumn(
mac = MACColumn()
class Meta:
model = Host
{% load i18n %}
<span title="{% blocktrans with vendor=record.hw_vendor|default:"n/a" %}Vendor: {{vendor}}{% endblocktrans %}">{{ record.mac }}</span>
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