import django_tables2 as tables
from netbox_ddns.models import ExtraDNSName
from utilities.tables import BaseTable, ToggleColumn
FORWARD_DNS = """
{% if record.forward_action is not None %}
{{ record.get_forward_action_display }}:
{{ record.get_forward_rcode_html_display }}
{% else %}
Not created
{% endif %}
"""
ACTIONS = """
{% if perms.dcim.change_extradnsname %}
{% endif %}
{% if perms.dcim.delete_extradnsname %}
{% endif %}
"""
class PrefixTable(BaseTable):
pk = ToggleColumn()
name = tables.Column()
last_update = tables.Column()
forward_dns = tables.TemplateColumn(template_code=FORWARD_DNS)
actions = tables.TemplateColumn(
template_code=ACTIONS,
attrs={'td': {'class': 'text-right text-nowrap noprint'}},
verbose_name=''
)
class Meta(BaseTable.Meta):
model = ExtraDNSName
fields = ('pk', 'name', 'last_update', 'forward_dns', 'actions')