1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #8246 - Circuits list view to display formatted commit rate

Adds a custom column class to format the commit rate in the circuits table view using humanize_speed template helper. Export still exports the raw number.
This commit is contained in:
Jason Yates
2022-01-08 21:55:07 +00:00
parent f1472d218e
commit f66a265fcf

View File

@ -22,6 +22,25 @@ CIRCUITTERMINATION_LINK = """
{% endif %}
"""
#
# Table columns
#
class CommitRateColumn(tables.TemplateColumn):
"""
Humanize the commit rate in the column view
"""
template_code = """
{% load helpers %}
{{ record.commit_rate|humanize_speed }}
"""
def __init__(self, *args, **kwargs):
super().__init__(template_code=self.template_code, *args, **kwargs)
def value(self, value):
return str(value) if value else None
#
# Providers
@ -119,6 +138,7 @@ class CircuitTable(BaseTable):
template_code=CIRCUITTERMINATION_LINK,
verbose_name='Side Z'
)
commit_rate = CommitRateColumn()
comments = MarkdownColumn()
tags = TagColumn(
url_name='circuits:circuit_list'