mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 16:26:09 -06:00
Merge branch 'develop' into feat/12110-generic-tab-view
This commit is contained in:
commit
fa09a4770f
@ -1042,6 +1042,9 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|||||||
queryset=VirtualDeviceContext.objects.all(),
|
queryset=VirtualDeviceContext.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
label='Virtual Device Contexts',
|
label='Virtual Device Contexts',
|
||||||
|
initial_params={
|
||||||
|
'interfaces': '$parent',
|
||||||
|
},
|
||||||
query_params={
|
query_params={
|
||||||
'device_id': '$device',
|
'device_id': '$device',
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db.models import Q
|
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from dcim.models import Device, Interface, Site
|
from dcim.models import Device, Interface, Site
|
||||||
@ -10,7 +9,9 @@ from ipam.constants import *
|
|||||||
from ipam.models import *
|
from ipam.models import *
|
||||||
from netbox.forms import NetBoxModelImportForm
|
from netbox.forms import NetBoxModelImportForm
|
||||||
from tenancy.models import Tenant
|
from tenancy.models import Tenant
|
||||||
from utilities.forms.fields import CSVChoiceField, CSVContentTypeField, CSVModelChoiceField, SlugField
|
from utilities.forms.fields import (
|
||||||
|
CSVChoiceField, CSVContentTypeField, CSVModelChoiceField, CSVModelMultipleChoiceField, SlugField
|
||||||
|
)
|
||||||
from virtualization.models import VirtualMachine, VMInterface
|
from virtualization.models import VirtualMachine, VMInterface
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -41,10 +42,25 @@ class VRFImportForm(NetBoxModelImportForm):
|
|||||||
to_field_name='name',
|
to_field_name='name',
|
||||||
help_text=_('Assigned tenant')
|
help_text=_('Assigned tenant')
|
||||||
)
|
)
|
||||||
|
import_targets = CSVModelMultipleChoiceField(
|
||||||
|
queryset=RouteTarget.objects.all(),
|
||||||
|
required=False,
|
||||||
|
to_field_name='name',
|
||||||
|
help_text=_('Import route targets')
|
||||||
|
)
|
||||||
|
export_targets = CSVModelMultipleChoiceField(
|
||||||
|
queryset=RouteTarget.objects.all(),
|
||||||
|
required=False,
|
||||||
|
to_field_name='name',
|
||||||
|
help_text=_('Export route targets')
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VRF
|
model = VRF
|
||||||
fields = ('name', 'rd', 'tenant', 'enforce_unique', 'description', 'comments', 'tags')
|
fields = (
|
||||||
|
'name', 'rd', 'tenant', 'enforce_unique', 'description', 'import_targets', 'export_targets', 'comments',
|
||||||
|
'tags',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RouteTargetImportForm(NetBoxModelImportForm):
|
class RouteTargetImportForm(NetBoxModelImportForm):
|
||||||
|
@ -54,7 +54,7 @@ class BaseTable(tables.Table):
|
|||||||
# 3. Meta.fields
|
# 3. Meta.fields
|
||||||
selected_columns = None
|
selected_columns = None
|
||||||
if user is not None and not isinstance(user, AnonymousUser):
|
if user is not None and not isinstance(user, AnonymousUser):
|
||||||
selected_columns = user.config.get(f"tables.{self.__class__.__name__}.columns")
|
selected_columns = user.config.get(f"tables.{self.name}.columns")
|
||||||
if not selected_columns:
|
if not selected_columns:
|
||||||
selected_columns = getattr(self.Meta, 'default_columns', self.Meta.fields)
|
selected_columns = getattr(self.Meta, 'default_columns', self.Meta.fields)
|
||||||
|
|
||||||
@ -113,6 +113,10 @@ class BaseTable(tables.Table):
|
|||||||
columns.append((name, column.verbose_name))
|
columns.append((name, column.verbose_name))
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self.__class__.__name__
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available_columns(self):
|
def available_columns(self):
|
||||||
return self._get_columns(visible=False)
|
return self._get_columns(visible=False)
|
||||||
@ -138,17 +142,16 @@ class BaseTable(tables.Table):
|
|||||||
"""
|
"""
|
||||||
# Save ordering preference
|
# Save ordering preference
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
table_name = self.__class__.__name__
|
|
||||||
if self.prefixed_order_by_field in request.GET:
|
if self.prefixed_order_by_field in request.GET:
|
||||||
if request.GET[self.prefixed_order_by_field]:
|
if request.GET[self.prefixed_order_by_field]:
|
||||||
# If an ordering has been specified as a query parameter, save it as the
|
# If an ordering has been specified as a query parameter, save it as the
|
||||||
# user's preferred ordering for this table.
|
# user's preferred ordering for this table.
|
||||||
ordering = request.GET.getlist(self.prefixed_order_by_field)
|
ordering = request.GET.getlist(self.prefixed_order_by_field)
|
||||||
request.user.config.set(f'tables.{table_name}.ordering', ordering, commit=True)
|
request.user.config.set(f'tables.{self.name}.ordering', ordering, commit=True)
|
||||||
else:
|
else:
|
||||||
# If the ordering has been set to none (empty), clear any existing preference.
|
# If the ordering has been set to none (empty), clear any existing preference.
|
||||||
request.user.config.clear(f'tables.{table_name}.ordering', commit=True)
|
request.user.config.clear(f'tables.{self.name}.ordering', commit=True)
|
||||||
elif ordering := request.user.config.get(f'tables.{table_name}.ordering'):
|
elif ordering := request.user.config.get(f'tables.{self.name}.ordering'):
|
||||||
# If no ordering has been specified, set the preferred ordering (if any).
|
# If no ordering has been specified, set the preferred ordering (if any).
|
||||||
self.order_by = ordering
|
self.order_by = ordering
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user