Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
File renamed without changes.
2 changes: 1 addition & 1 deletion nautobot_bgp_models/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AutonomousSystemForm(NautobotModelForm):

class Meta:
model = models.AutonomousSystem
fields = ("asn", "description", "provider", "status", "tags")
fields = ("asn", "description", "tenant", "provider", "status", "tags")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest using TenancyForm as a mixin on the form class, which will automatically add the relevant form fields.



class AutonomousSystemFilterForm(NautobotFilterForm):
Copy link
Contributor

@glennmatthews glennmatthews Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, please add TenancyFilterForm to this form class. You'll also need to update the AutonomousSystemFilterSet with the TenancyModelFilterSetMixin mixin class to support filtering by tenant.

Expand Down
20 changes: 20 additions & 0 deletions nautobot_bgp_models/migrations/0011_autonomoussystem_tenant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.17 on 2025-02-26 19:23

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('tenancy', '0009_update_all_charfields_max_length_to_255'),
('nautobot_bgp_models', '0010_alter_autonomoussystem_status_and_more'),
]

operations = [
migrations.AddField(
model_name='autonomoussystem',
name='tenant',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='tenancy.tenant'),
),
]
1 change: 1 addition & 0 deletions nautobot_bgp_models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class AutonomousSystem(PrimaryModel):
asn = ASNField(unique=True, verbose_name="ASN", help_text="32-bit autonomous system number")
description = models.CharField(max_length=200, blank=True)
provider = models.ForeignKey(to=Provider, on_delete=models.PROTECT, blank=True, null=True)
tenant = models.ForeignKey(to=Tenant, on_delete=models.PROTECT, blank=True, null=True)
status = StatusField(null=True)

class Meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<td>Description</td>
<td>{{ object.description }}</td>
</tr>
<tr>
<td>Tenant</td>
<td>{{ object.tenant | hyperlinked_object }}</td>
</tr>
<tr>
<td>Status</td>
<td>
Expand Down
Loading