Compare commits

..

9 Commits

Author SHA1 Message Date
Arthur
8816af1389 move attrs to separate file
CI / build (20.x, 3.12) (push) Failing after 12s
CI / build (20.x, 3.13) (push) Failing after 10s
CI / build (20.x, 3.14) (push) Failing after 10s
2026-03-18 15:04:07 -07:00
Arthur
ca76d37ffe fix breadcrumb on ANS 2026-03-18 14:13:26 -07:00
Arthur
ef0b0eaee9 fix breadcrumb on Application Service 2026-03-18 14:10:34 -07:00
Arthur
8391c6ae95 fix add VLAN button 2026-03-18 13:52:54 -07:00
Arthur
0752fd2c63 fix add aggregate button 2026-03-18 13:51:04 -07:00
Arthur
ddb8ce90eb fix add prefix button 2026-03-18 13:49:15 -07:00
Arthur
6193ef506f fix addressing details modal 2026-03-18 13:47:33 -07:00
Arthur
91e0b661a4 fix Route Target view 2026-03-18 12:55:17 -07:00
Arthur
cef3eb0ab0 fix VRF view 2026-03-18 12:48:06 -07:00
10 changed files with 170 additions and 64 deletions
-1
View File
@@ -364,7 +364,6 @@ class VLANTranslationPolicy(PrimaryModel):
max_length=100,
unique=True,
)
class Meta:
verbose_name = _('VLAN translation policy')
verbose_name_plural = _('VLAN translation policies')
+25
View File
@@ -0,0 +1,25 @@
from django.template.loader import render_to_string
from netbox.ui import attrs
class VRFDisplayAttr(attrs.ObjectAttribute):
"""
Renders a VRF reference, displaying 'Global' when no VRF is assigned.
"""
template_name = 'ipam/attrs/vrf.html'
def render(self, obj, context):
value = self.get_value(obj)
return render_to_string(self.template_name, {
**self.get_context(obj, context),
'name': context.get('name', ''),
'value': value,
})
class VRFDisplayWithRDAttr(VRFDisplayAttr):
"""
Renders a VRF reference with its route distinguisher.
"""
template_name = 'ipam/attrs/vrf_with_rd.html'
+1 -22
View File
@@ -1,31 +1,10 @@
from django.contrib.contenttypes.models import ContentType
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from netbox.ui import actions, attrs, panels
class VRFDisplayAttr(attrs.ObjectAttribute):
"""
Renders a VRF reference, displaying 'Global' when no VRF is assigned.
"""
template_name = 'ipam/attrs/vrf.html'
def render(self, obj, context):
value = self.get_value(obj)
return render_to_string(self.template_name, {
**self.get_context(obj, context),
'name': context.get('name', ''),
'value': value,
})
class VRFDisplayWithRDAttr(VRFDisplayAttr):
"""
Renders a VRF reference with its route distinguisher.
"""
template_name = 'ipam/attrs/vrf_with_rd.html'
from .attrs import VRFDisplayAttr, VRFDisplayWithRDAttr
class FHRPGroupAssignmentsPanel(panels.ObjectPanel):
+59 -41
View File
@@ -50,20 +50,26 @@ class VRFListView(generic.ObjectListView):
@register_model_view(VRF)
class VRFView(GetRelatedModelsMixin, generic.ObjectView):
queryset = VRF.objects.all()
layout = layout.SimpleLayout(
left_panels=[
panels.VRFPanel(),
TagsPanel(),
],
right_panels=[
RelatedObjectsPanel(),
CustomFieldsPanel(),
CommentsPanel(),
],
bottom_panels=[
ContextTablePanel('import_targets_table', title=_('Import Route Targets')),
ContextTablePanel('export_targets_table', title=_('Export Route Targets')),
],
layout = layout.Layout(
layout.Row(
layout.Column(
panels.VRFPanel(),
TagsPanel(),
),
layout.Column(
RelatedObjectsPanel(),
CustomFieldsPanel(),
CommentsPanel(),
),
),
layout.Row(
layout.Column(
ContextTablePanel('import_targets_table', title=_('Import Route Targets')),
),
layout.Column(
ContextTablePanel('export_targets_table', title=_('Export Route Targets')),
),
),
)
def get_extra_context(self, request, instance):
@@ -158,37 +164,49 @@ class RouteTargetListView(generic.ObjectListView):
@register_model_view(RouteTarget)
class RouteTargetView(generic.ObjectView):
queryset = RouteTarget.objects.all()
layout = layout.SimpleLayout(
left_panels=[
panels.RouteTargetPanel(),
TagsPanel(),
],
right_panels=[
CustomFieldsPanel(),
CommentsPanel(),
],
bottom_panels=[
ObjectsTablePanel(
'ipam.vrf',
filters={'import_target_id': lambda ctx: ctx['object'].pk},
title=_('Importing VRFs'),
layout = layout.Layout(
layout.Row(
layout.Column(
panels.RouteTargetPanel(),
TagsPanel(),
),
ObjectsTablePanel(
'ipam.vrf',
filters={'export_target_id': lambda ctx: ctx['object'].pk},
title=_('Exporting VRFs'),
layout.Column(
CustomFieldsPanel(),
CommentsPanel(),
),
ObjectsTablePanel(
'vpn.l2vpn',
filters={'import_target_id': lambda ctx: ctx['object'].pk},
title=_('Importing L2VPNs'),
),
layout.Row(
layout.Column(
ObjectsTablePanel(
'ipam.vrf',
filters={'import_target_id': lambda ctx: ctx['object'].pk},
title=_('Importing VRFs'),
),
),
ObjectsTablePanel(
'vpn.l2vpn',
filters={'export_target_id': lambda ctx: ctx['object'].pk},
title=_('Exporting L2VPNs'),
layout.Column(
ObjectsTablePanel(
'ipam.vrf',
filters={'export_target_id': lambda ctx: ctx['object'].pk},
title=_('Exporting VRFs'),
),
),
],
),
layout.Row(
layout.Column(
ObjectsTablePanel(
'vpn.l2vpn',
filters={'import_target_id': lambda ctx: ctx['object'].pk},
title=_('Importing L2VPNs'),
),
),
layout.Column(
ObjectsTablePanel(
'vpn.l2vpn',
filters={'export_target_id': lambda ctx: ctx['object'].pk},
title=_('Exporting L2VPNs'),
),
),
),
)
+9
View File
@@ -1 +1,10 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% block breadcrumbs %}
{{ block.super }}
<li class="breadcrumb-item"><a href="{% url 'ipam:asn_list' %}?rir_id={{ object.rir.pk }}">{{ object.rir }}</a></li>
{% if object.range %}
<li class="breadcrumb-item"><a href="{% url 'ipam:asn_list' %}?range_id={{ object.range.pk }}">{{ object.range }}</a></li>
{% endif %}
{% endblock breadcrumbs %}
+37
View File
@@ -1,6 +1,7 @@
{% extends 'generic/object.html' %}
{% load buttons %}
{% load helpers %}
{% load i18n %}
{% block breadcrumbs %}
{{ block.super }}
@@ -8,3 +9,39 @@
<li class="breadcrumb-item"><a href="{% url 'ipam:prefix_list' %}?vrf_id={{ object.vrf.pk }}">{{ object.vrf }}</a></li>
{% endif %}
{% endblock %}
{% block modals %}
{{ block.super }}
{% if object.prefix.version == 4 %}
<div class="modal fade" id="prefix-modal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Prefix Details" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body p-0">
<table class="table table-hover attr-table m-0">
<tr>
<th scope="row">{% trans "Network Address" %}</th>
<td>{{ object.prefix.network }}</td>
</tr>
<tr>
<th scope="row">{% trans "Network Mask" %}</th>
<td>{{ object.prefix.netmask }}</td>
</tr>
<tr>
<th scope="row">{% trans "Wildcard Mask" %}</th>
<td>{{ object.prefix.hostmask }}</td>
</tr>
<tr>
<th scope="row">{% trans "Broadcast Address" %}</th>
<td>{{ object.prefix.broadcast }}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock modals %}
+9
View File
@@ -1 +1,10 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% block extra_controls %}
{% if perms.ipam.add_aggregate %}
<a href="{% url 'ipam:aggregate_add' %}?rir={{ object.pk }}" class="btn btn-primary">
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Add Aggregate" %}
</a>
{% endif %}
{% endblock extra_controls %}
+9
View File
@@ -1 +1,10 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% block extra_controls %}
{% if perms.ipam.add_prefix %}
<a href="{% url 'ipam:prefix_add' %}?role={{ object.pk }}" class="btn btn-primary">
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Add Prefix" %}
</a>
{% endif %}
{% endblock extra_controls %}
+12
View File
@@ -1 +1,13 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% block breadcrumbs %}
{{ block.super }}
{% if object.parent and breadcrumb_queryparam %}
<li class="breadcrumb-item">
<a href="{% url 'ipam:service_list' %}?{{ breadcrumb_queryparam }}={{ object.parent.pk }}">
{{ object.parent }}
</a>
</li>
{% endif %}
{% endblock breadcrumbs %}
+9
View File
@@ -1 +1,10 @@
{% extends 'generic/object.html' %}
{% load i18n %}
{% block extra_controls %}
{% if perms.ipam.add_vlan %}
<a href="{% url 'ipam:vlan_add' %}?group={{ object.pk }}" class="btn btn-primary">
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Add VLAN" %}
</a>
{% endif %}
{% endblock extra_controls %}