Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions netbox_bgp/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,14 +582,14 @@ class RoutingPolicyForm(NetBoxModelForm):

class Meta:
model = RoutingPolicy
fields = ["name", "description", "tags", "comments"]
fields = ["name", "description", "weight", "tags", "comments"]


class RoutingPolicyImportForm(NetBoxModelImportForm):

class Meta:
model = RoutingPolicy
fields = ("name", "description", "tags")
fields = ("name", "description", "weight", "tags")


class RoutingPolicyBulkEditForm(NetBoxModelBulkEditForm):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.2.5 on 2025-09-29 20:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('netbox_bgp', '0035_alter_aspathlist_options_and_more'),
]

operations = [
migrations.AlterModelOptions(
name='routingpolicy',
options={'ordering': ['weight', 'name']},
),
migrations.AddField(
model_name='routingpolicy',
name='weight',
field=models.PositiveIntegerField(blank=True, null=True),
),
]
8 changes: 6 additions & 2 deletions netbox_bgp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_action_color(self):
return ActionChoices.colors.get(self.action)

class Meta:
ordering = ['aspath_list', 'index']
ordering = ('aspath_list', 'index')


class RoutingPolicy(NetBoxModel):
Expand All @@ -87,11 +87,15 @@ class RoutingPolicy(NetBoxModel):
comments = models.TextField(
blank=True
)
weight = models.PositiveIntegerField(
blank=True,
null=True
)

class Meta:
verbose_name_plural = 'Routing Policies'
unique_together = ['name', 'description']
ordering = ['name']
ordering = ['weight', 'name']

def __str__(self):
return self.name
Expand Down
2 changes: 1 addition & 1 deletion netbox_bgp/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class RoutingPolicyTable(NetBoxTable):

class Meta(NetBoxTable.Meta):
model = RoutingPolicy
fields = ('pk', 'name', 'description', 'actions')
fields = ('pk', 'name', 'description', 'weight', 'actions')


class BGPPeerGroupTable(NetBoxTable):
Expand Down
4 changes: 4 additions & 0 deletions netbox_bgp/templates/netbox_bgp/routingpolicy.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ <h5 class="card-header">
<td>Description</td>
<td>{{ object.description|placeholder }}</td>
</tr>
<tr>
<td>Weight</td>
<td>{{ object.weight|placeholder }}</td>
</tr>
</table>
</div>
</div>
Expand Down