diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index 9b4a8475b..e9c8b362e 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -9,7 +9,7 @@ from dcim.choices import * from dcim.constants import * from dcim.models import * from extras.models import ConfigTemplate -from ipam.models import VRF +from ipam.models import VRF, IPAddress from netbox.forms import NetBoxModelImportForm from tenancy.models import Tenant from utilities.forms.fields import ( @@ -1435,9 +1435,33 @@ class VirtualDeviceContextImportForm(NetBoxModelImportForm): label=_('Status'), choices=VirtualDeviceContextStatusChoices, ) + primary_ip4 = CSVModelChoiceField( + label=_('Primary IPv4'), + queryset=IPAddress.objects.all(), + required=False, + to_field_name='address', + help_text=_('IPv4 address with mask, e.g. 1.2.3.4/24') + ) + primary_ip6 = CSVModelChoiceField( + label=_('Primary IPv6'), + queryset=IPAddress.objects.all(), + required=False, + to_field_name='address', + help_text=_('IPv6 address with prefix length, e.g. 2001:db8::1/64') + ) class Meta: fields = [ - 'name', 'device', 'status', 'tenant', 'identifier', 'comments', + 'name', 'device', 'status', 'tenant', 'identifier', 'comments', 'primary_ip4', 'primary_ip6', ] model = VirtualDeviceContext + + def __init__(self, data=None, *args, **kwargs): + super().__init__(data, *args, **kwargs) + + if data: + + # Limit primary_ip4/ip6 querysets by assigned device + params = {f"interface__device__{self.fields['device'].to_field_name}": data.get('device')} + self.fields['primary_ip4'].queryset = self.fields['primary_ip4'].queryset.filter(**params) + self.fields['primary_ip6'].queryset = self.fields['primary_ip6'].queryset.filter(**params) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 1f5b73603..98665a7a0 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -3253,10 +3253,10 @@ class CableEditView(generic.ObjectEditView): doesn't currently provide a hook for dynamic class resolution. """ a_terminations_type = CABLE_TERMINATION_TYPES.get( - request.GET.get('a_terminations_type') or request.POST.get('a_terminations_type') + request.POST.get('a_terminations_type') or request.GET.get('a_terminations_type') ) b_terminations_type = CABLE_TERMINATION_TYPES.get( - request.GET.get('b_terminations_type') or request.POST.get('b_terminations_type') + request.POST.get('b_terminations_type') or request.GET.get('b_terminations_type') ) if obj.pk: diff --git a/netbox/ipam/models/asns.py b/netbox/ipam/models/asns.py index ba483a745..d02efd91c 100644 --- a/netbox/ipam/models/asns.py +++ b/netbox/ipam/models/asns.py @@ -149,3 +149,7 @@ class ASN(PrimaryModel): return f'{self.asn} ({self.asn // 65536}.{self.asn % 65536})' else: return self.asn + + @property + def prefixed_name(self): + return f'AS{self.asn_with_asdot}' diff --git a/netbox/ipam/search.py b/netbox/ipam/search.py index 59b741b8f..414321b7d 100644 --- a/netbox/ipam/search.py +++ b/netbox/ipam/search.py @@ -19,6 +19,7 @@ class ASNIndex(SearchIndex): model = models.ASN fields = ( ('asn', 100), + ('prefixed_name', 110), ('description', 500), ) display_attrs = ('rir', 'tenant', 'description') diff --git a/netbox/netbox/preferences.py b/netbox/netbox/preferences.py index d911aabb0..4fdb7e31f 100644 --- a/netbox/netbox/preferences.py +++ b/netbox/netbox/preferences.py @@ -1,5 +1,5 @@ from django.conf import settings -from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy as _ from netbox.registry import registry from users.preferences import UserPreference diff --git a/netbox/project-static/dist/netbox.css b/netbox/project-static/dist/netbox.css index f1b9e24e2..6f4f8ac36 100644 Binary files a/netbox/project-static/dist/netbox.css and b/netbox/project-static/dist/netbox.css differ diff --git a/netbox/project-static/styles/overrides/_tabler.scss b/netbox/project-static/styles/overrides/_tabler.scss index 814a6d82b..252da8f4a 100644 --- a/netbox/project-static/styles/overrides/_tabler.scss +++ b/netbox/project-static/styles/overrides/_tabler.scss @@ -128,6 +128,9 @@ body[data-bs-theme=dark] { .footer .text-primary { color: white !important; } + .toast { + color: var(--#{$prefix}body-color); + } } // Do not apply padding to elements inside a
diff --git a/netbox/utilities/templates/form_helpers/render_field.html b/netbox/utilities/templates/form_helpers/render_field.html
index 47d1f8d10..9abaaa633 100644
--- a/netbox/utilities/templates/form_helpers/render_field.html
+++ b/netbox/utilities/templates/form_helpers/render_field.html
@@ -6,9 +6,11 @@
 
   {# Render the field label (if any), except for checkboxes #}
   {% if label and not field|widget_type == 'checkboxinput' %}
-    
+    
+ +
{% endif %} {# Render the field itself #}