-
Notifications
You must be signed in to change notification settings - Fork 16
Add tenant attribute to AutonomousSystem model #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
| class Meta: | ||
| model = models.AutonomousSystem | ||
| fields = ("asn", "description", "provider", "status", "tags") | ||
| fields = ("asn", "description", "tenant", "provider", "status", "tags") |
There was a problem hiding this comment.
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.
| fields = ("asn", "description", "tenant", "provider", "status", "tags") | ||
|
|
||
|
|
||
| class AutonomousSystemFilterForm(NautobotFilterForm): |
There was a problem hiding this comment.
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.
|
Maybe also add an appropriate |
|
I will take a look at the above and make those updates. |
|
Updated the code to this PR. Let me know if this is what you were requesting. One minor update to the models under AutonomousSytem for the tenant field was to include a related_name. |
| "description": "icontains", | ||
| }, | ||
| ) | ||
| tenant = django_filters.ModelMultipleChoiceFilter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible to use nautobot.tenancy.filters.mixins.TenancyModelFilterSetMixin instead of this explicit declaration?
| tenant = tables.LinkColumn( | ||
| viewname="tenancy:tenant", | ||
| args=[A("tenant__pk")], | ||
| verbose_name="Tenant", | ||
| text=lambda record: record.tenant.name if record.tenant else "", | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is all this configuration needed? I would have thought tenant = tables.Column(linkify=True) would work just as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have TenantColumn as well.
from nautobot.tenancy.tables import TenantColumn
...
tenant = TenantColumn()
|
Please update unit tests too. |
Closes: Add tenant attribute to AutonomousSystem model #191
What's Changed
Add a ForeignKey field for Tenant to the AutonomousSystem model, update the forms.py and autonomoussystemrange_retrieve.html to reference the Tenant field for display and input.
To Do