Skip to content

Commit

Permalink
Closes #13150: Wrap table column headers with gettext()
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Stretch <[email protected]>
  • Loading branch information
arthanson and jeremystretch authored Jul 31, 2023
1 parent 34a9605 commit e284cd7
Show file tree
Hide file tree
Showing 30 changed files with 822 additions and 327 deletions.
21 changes: 13 additions & 8 deletions netbox/circuits/tables/circuits.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
import django_tables2 as tables

from circuits.models import *
Expand All @@ -24,15 +25,16 @@

class CircuitTypeTable(NetBoxTable):
name = tables.Column(
linkify=True
linkify=True,
verbose_name=_('Name'),
)
tags = columns.TagColumn(
url_name='circuits:circuittype_list'
)
circuit_count = columns.LinkedCountColumn(
viewname='circuits:circuit_list',
url_params={'type_id': 'pk'},
verbose_name='Circuits'
verbose_name=_('Circuits')
)

class Meta(NetBoxTable.Meta):
Expand All @@ -46,28 +48,31 @@ class Meta(NetBoxTable.Meta):
class CircuitTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
cid = tables.Column(
linkify=True,
verbose_name='Circuit ID'
verbose_name=_('Circuit ID')
)
provider = tables.Column(
verbose_name=_('Provider'),
linkify=True
)
provider_account = tables.Column(
linkify=True,
verbose_name='Account'
verbose_name=_('Account')
)
status = columns.ChoiceFieldColumn()
termination_a = tables.TemplateColumn(
template_code=CIRCUITTERMINATION_LINK,
verbose_name='Side A'
verbose_name=_('Side A')
)
termination_z = tables.TemplateColumn(
template_code=CIRCUITTERMINATION_LINK,
verbose_name='Side Z'
verbose_name=_('Side Z')
)
commit_rate = CommitRateColumn(
verbose_name='Commit Rate'
verbose_name=_('Commit Rate')
)
comments = columns.MarkdownColumn(
verbose_name=_('Comments'),
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='circuits:circuit_list'
)
Expand Down
36 changes: 25 additions & 11 deletions netbox/circuits/tables/providers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import django_tables2 as tables
from django.utils.translation import gettext_lazy as _
from circuits.models import *
from django_tables2.utils import Accessor
from tenancy.tables import ContactsColumnMixin
Expand All @@ -14,35 +15,38 @@

class ProviderTable(ContactsColumnMixin, NetBoxTable):
name = tables.Column(
verbose_name=_('Name'),
linkify=True
)
accounts = columns.ManyToManyColumn(
linkify_item=True,
verbose_name='Accounts'
verbose_name=_('Accounts')
)
account_count = columns.LinkedCountColumn(
accessor=tables.A('accounts__count'),
viewname='circuits:provideraccount_list',
url_params={'account_id': 'pk'},
verbose_name='Account Count'
verbose_name=_('Account Count')
)
asns = columns.ManyToManyColumn(
linkify_item=True,
verbose_name='ASNs'
verbose_name=_('ASNs')
)
asn_count = columns.LinkedCountColumn(
accessor=tables.A('asns__count'),
viewname='ipam:asn_list',
url_params={'provider_id': 'pk'},
verbose_name='ASN Count'
verbose_name=_('ASN Count')
)
circuit_count = columns.LinkedCountColumn(
accessor=Accessor('count_circuits'),
viewname='circuits:circuit_list',
url_params={'provider_id': 'pk'},
verbose_name='Circuits'
verbose_name=_('Circuits')
)
comments = columns.MarkdownColumn(
verbose_name=_('Comments'),
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='circuits:provider_list'
)
Expand All @@ -58,19 +62,25 @@ class Meta(NetBoxTable.Meta):

class ProviderAccountTable(ContactsColumnMixin, NetBoxTable):
account = tables.Column(
linkify=True
linkify=True,
verbose_name=_('Account'),
)
name = tables.Column(
verbose_name=_('Name'),
)
name = tables.Column()
provider = tables.Column(
verbose_name=_('Provider'),
linkify=True
)
circuit_count = columns.LinkedCountColumn(
accessor=Accessor('count_circuits'),
viewname='circuits:circuit_list',
url_params={'provider_account_id': 'pk'},
verbose_name='Circuits'
verbose_name=_('Circuits')
)
comments = columns.MarkdownColumn(
verbose_name=_('Comments'),
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='circuits:provideraccount_list'
)
Expand All @@ -86,12 +96,16 @@ class Meta(NetBoxTable.Meta):

class ProviderNetworkTable(NetBoxTable):
name = tables.Column(
verbose_name=_('Name'),
linkify=True
)
provider = tables.Column(
verbose_name=_('Provider'),
linkify=True
)
comments = columns.MarkdownColumn()
comments = columns.MarkdownColumn(
verbose_name=_('Comments'),
)
tags = columns.TagColumn(
url_name='circuits:providernetwork_list'
)
Expand Down
20 changes: 16 additions & 4 deletions netbox/core/tables/data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
import django_tables2 as tables

from core.models import *
Expand All @@ -11,11 +12,18 @@

class DataSourceTable(NetBoxTable):
name = tables.Column(
verbose_name=_('Name'),
linkify=True
)
type = columns.ChoiceFieldColumn()
status = columns.ChoiceFieldColumn()
enabled = columns.BooleanColumn()
type = columns.ChoiceFieldColumn(
verbose_name=_('Type'),
)
status = columns.ChoiceFieldColumn(
verbose_name=_('Status'),
)
enabled = columns.BooleanColumn(
verbose_name=_('Enabled'),
)
tags = columns.TagColumn(
url_name='core:datasource_list'
)
Expand All @@ -34,12 +42,16 @@ class Meta(NetBoxTable.Meta):

class DataFileTable(NetBoxTable):
source = tables.Column(
verbose_name=_('Source'),
linkify=True
)
path = tables.Column(
verbose_name=_('Path'),
linkify=True
)
last_updated = columns.DateTimeColumn()
last_updated = columns.DateTimeColumn(
verbose_name=_('Last updated'),
)
actions = columns.ActionsColumn(
actions=('delete',)
)
Expand Down
29 changes: 22 additions & 7 deletions netbox/core/tables/jobs.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
import django_tables2 as tables
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _

from netbox.tables import NetBoxTable, columns
from ..models import Job


class JobTable(NetBoxTable):
id = tables.Column(
verbose_name=_('ID'),
linkify=True
)
name = tables.Column(
verbose_name=_('Name'),
linkify=True
)
object_type = columns.ContentTypeColumn(
verbose_name=_('Type')
)
object = tables.Column(
verbose_name=_('Object'),
linkify=True
)
status = columns.ChoiceFieldColumn()
created = columns.DateTimeColumn()
scheduled = columns.DateTimeColumn()
interval = columns.DurationColumn()
started = columns.DateTimeColumn()
completed = columns.DateTimeColumn()
status = columns.ChoiceFieldColumn(
verbose_name=_('Status'),
)
created = columns.DateTimeColumn(
verbose_name=_('Created'),
)
scheduled = columns.DateTimeColumn(
verbose_name=_('Scheduled'),
)
interval = columns.DurationColumn(
verbose_name=_('Interval'),
)
started = columns.DateTimeColumn(
verbose_name=_('Started'),
)
completed = columns.DateTimeColumn(
verbose_name=_('Completed'),
)
actions = columns.ActionsColumn(
actions=('delete',)
)
Expand Down
21 changes: 11 additions & 10 deletions netbox/dcim/tables/cables.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
import django_tables2 as tables
from django_tables2.utils import Accessor
from django.utils.safestring import mark_safe
Expand Down Expand Up @@ -50,60 +51,60 @@ class CableTable(TenancyColumnsMixin, NetBoxTable):
a_terminations = CableTerminationsColumn(
cable_end='A',
orderable=False,
verbose_name='Termination A'
verbose_name=_('Termination A')
)
b_terminations = CableTerminationsColumn(
cable_end='B',
orderable=False,
verbose_name='Termination B'
verbose_name=_('Termination B')
)
device_a = CableTerminationsColumn(
cable_end='A',
attr='_device',
orderable=False,
verbose_name='Device A'
verbose_name=_('Device A')
)
device_b = CableTerminationsColumn(
cable_end='B',
attr='_device',
orderable=False,
verbose_name='Device B'
verbose_name=_('Device B')
)
location_a = CableTerminationsColumn(
cable_end='A',
attr='_location',
orderable=False,
verbose_name='Location A'
verbose_name=_('Location A')
)
location_b = CableTerminationsColumn(
cable_end='B',
attr='_location',
orderable=False,
verbose_name='Location B'
verbose_name=_('Location B')
)
rack_a = CableTerminationsColumn(
cable_end='A',
attr='_rack',
orderable=False,
verbose_name='Rack A'
verbose_name=_('Rack A')
)
rack_b = CableTerminationsColumn(
cable_end='B',
attr='_rack',
orderable=False,
verbose_name='Rack B'
verbose_name=_('Rack B')
)
site_a = CableTerminationsColumn(
cable_end='A',
attr='_site',
orderable=False,
verbose_name='Site A'
verbose_name=_('Site A')
)
site_b = CableTerminationsColumn(
cable_end='B',
attr='_site',
orderable=False,
verbose_name='Site B'
verbose_name=_('Site B')
)
status = columns.ChoiceFieldColumn()
length = columns.TemplateColumn(
Expand Down
15 changes: 10 additions & 5 deletions netbox/dcim/tables/connections.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
import django_tables2 as tables
from django_tables2.utils import Accessor

Expand All @@ -18,15 +19,16 @@

class ConsoleConnectionTable(PathEndpointTable):
device = tables.Column(
verbose_name=_('Device'),
linkify=True
)
name = tables.Column(
linkify=True,
verbose_name='Console Port'
verbose_name=_('Console Port')
)
reachable = columns.BooleanColumn(
accessor=Accessor('_path__is_active'),
verbose_name='Reachable'
verbose_name=_('Reachable')
)

class Meta(BaseTable.Meta):
Expand All @@ -36,15 +38,16 @@ class Meta(BaseTable.Meta):

class PowerConnectionTable(PathEndpointTable):
device = tables.Column(
verbose_name=_('Device'),
linkify=True
)
name = tables.Column(
linkify=True,
verbose_name='Power Port'
verbose_name=_('Power Port')
)
reachable = columns.BooleanColumn(
accessor=Accessor('_path__is_active'),
verbose_name='Reachable'
verbose_name=_('Reachable')
)

class Meta(BaseTable.Meta):
Expand All @@ -54,16 +57,18 @@ class Meta(BaseTable.Meta):

class InterfaceConnectionTable(PathEndpointTable):
device = tables.Column(
verbose_name=_('Device'),
accessor=Accessor('device'),
linkify=True
)
interface = tables.Column(
verbose_name=_('Interface'),
accessor=Accessor('name'),
linkify=True
)
reachable = columns.BooleanColumn(
accessor=Accessor('_path__is_active'),
verbose_name='Reachable'
verbose_name=_('Reachable')
)

class Meta(BaseTable.Meta):
Expand Down
Loading

0 comments on commit e284cd7

Please sign in to comment.