mirror of
				https://github.com/netbox-community/netbox.git
				synced 2024-05-10 07:54:54 +00:00 
			
		
		
		
	Adds two fields to all relevant tables to allow the addition of Created & Last Updated columns. All tables with a Configure Table option were updated. Some sections reformatted to comply with E501 line length as a result of changes
		
			
				
	
	
		
			74 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| import django_tables2 as tables
 | |
| 
 | |
| from tenancy.tables import TenantColumn
 | |
| from utilities.tables import BaseTable, BooleanColumn, TagColumn, TemplateColumn, ToggleColumn
 | |
| from ipam.models import *
 | |
| 
 | |
| __all__ = (
 | |
|     'RouteTargetTable',
 | |
|     'VRFTable',
 | |
| )
 | |
| 
 | |
| VRF_TARGETS = """
 | |
| {% for rt in value.all %}
 | |
|   <a href="{{ rt.get_absolute_url }}">{{ rt }}</a>{% if not forloop.last %}<br />{% endif %}
 | |
| {% endfor %}
 | |
| """
 | |
| 
 | |
| 
 | |
| #
 | |
| # VRFs
 | |
| #
 | |
| 
 | |
| class VRFTable(BaseTable):
 | |
|     pk = ToggleColumn()
 | |
|     name = tables.Column(
 | |
|         linkify=True
 | |
|     )
 | |
|     rd = tables.Column(
 | |
|         verbose_name='RD'
 | |
|     )
 | |
|     tenant = TenantColumn()
 | |
|     enforce_unique = BooleanColumn(
 | |
|         verbose_name='Unique'
 | |
|     )
 | |
|     import_targets = TemplateColumn(
 | |
|         template_code=VRF_TARGETS,
 | |
|         orderable=False
 | |
|     )
 | |
|     export_targets = TemplateColumn(
 | |
|         template_code=VRF_TARGETS,
 | |
|         orderable=False
 | |
|     )
 | |
|     tags = TagColumn(
 | |
|         url_name='ipam:vrf_list'
 | |
|     )
 | |
| 
 | |
|     class Meta(BaseTable.Meta):
 | |
|         model = VRF
 | |
|         fields = (
 | |
|             'pk', 'id', 'name', 'rd', 'tenant', 'enforce_unique', 'description', 'import_targets', 'export_targets',
 | |
|             'tags', 'created', 'last_updated',
 | |
|         )
 | |
|         default_columns = ('pk', 'name', 'rd', 'tenant', 'description')
 | |
| 
 | |
| 
 | |
| #
 | |
| # Route targets
 | |
| #
 | |
| 
 | |
| class RouteTargetTable(BaseTable):
 | |
|     pk = ToggleColumn()
 | |
|     name = tables.Column(
 | |
|         linkify=True
 | |
|     )
 | |
|     tenant = TenantColumn()
 | |
|     tags = TagColumn(
 | |
|         url_name='ipam:vrf_list'
 | |
|     )
 | |
| 
 | |
|     class Meta(BaseTable.Meta):
 | |
|         model = RouteTarget
 | |
|         fields = ('pk', 'id', 'name', 'tenant', 'description', 'tags', 'created', 'last_updated',)
 | |
|         default_columns = ('pk', 'name', 'tenant', 'description')
 |