From 503e781f48b8337d15a7a5aaa92cde386115cfac Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Thu, 26 Sep 2024 09:44:32 -0700 Subject: [PATCH 1/6] 17476 Upgrade to Django 5.1 --- netbox/extras/forms/bulk_import.py | 6 +++--- netbox/ipam/forms/model_forms.py | 18 +++++++++--------- netbox/vpn/forms/model_forms.py | 14 +++++++------- requirements.txt | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/netbox/extras/forms/bulk_import.py b/netbox/extras/forms/bulk_import.py index 55c9cd764f4..6e2fe6d6342 100644 --- a/netbox/extras/forms/bulk_import.py +++ b/netbox/extras/forms/bulk_import.py @@ -192,7 +192,7 @@ class EventRuleImportForm(NetBoxModelImportForm): label=_('Event types'), help_text=_('The event type(s) which will trigger this rule') ) - action_object = forms.CharField( + action_object_key = forms.CharField( label=_('Action object'), required=True, help_text=_('Webhook name or script as dotted path module.Class') @@ -202,13 +202,13 @@ class Meta: model = EventRule fields = ( 'name', 'description', 'enabled', 'conditions', 'object_types', 'event_types', 'action_type', - 'action_object', 'comments', 'tags' + 'action_object_key', 'comments', 'tags' ) def clean(self): super().clean() - action_object = self.cleaned_data.get('action_object') + action_object = self.cleaned_data.get('action_object_key') action_type = self.cleaned_data.get('action_type') if action_object and action_type: # Webhook diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index f98f8b24ff1..fd9dddc2fe9 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -574,7 +574,7 @@ class VLANGroupForm(NetBoxModelForm): required=False, label=_('Scope type') ) - scope = DynamicModelChoiceField( + scope_key = DynamicModelChoiceField( label=_('Scope'), queryset=Site.objects.none(), # Initial queryset required=False, @@ -585,13 +585,13 @@ class VLANGroupForm(NetBoxModelForm): fieldsets = ( FieldSet('name', 'slug', 'description', 'tags', name=_('VLAN Group')), FieldSet('vid_ranges', name=_('Child VLANs')), - FieldSet('scope_type', 'scope', name=_('Scope')), + FieldSet('scope_type', 'scope_key', name=_('Scope')), ) class Meta: model = VLANGroup fields = [ - 'name', 'slug', 'description', 'vid_ranges', 'scope_type', 'scope', 'tags', + 'name', 'slug', 'description', 'vid_ranges', 'scope_type', 'scope_key', 'tags', ] def __init__(self, *args, **kwargs): @@ -599,7 +599,7 @@ def __init__(self, *args, **kwargs): initial = kwargs.get('initial', {}) if instance is not None and instance.scope: - initial['scope'] = instance.scope + initial['scope_key'] = instance.scope kwargs['initial'] = initial super().__init__(*args, **kwargs) @@ -608,15 +608,15 @@ def __init__(self, *args, **kwargs): try: scope_type = ContentType.objects.get(pk=scope_type_id) model = scope_type.model_class() - self.fields['scope'].queryset = model.objects.all() - self.fields['scope'].widget.attrs['selector'] = model._meta.label_lower - self.fields['scope'].disabled = False - self.fields['scope'].label = _(bettertitle(model._meta.verbose_name)) + self.fields['scope_key'].queryset = model.objects.all() + self.fields['scope_key'].widget.attrs['selector'] = model._meta.label_lower + self.fields['scope_key'].disabled = False + self.fields['scope_key'].label = _(bettertitle(model._meta.verbose_name)) except ObjectDoesNotExist: pass if self.instance and scope_type_id != self.instance.scope_type_id: - self.initial['scope'] = None + self.initial['scope_key'] = None def clean(self): super().clean() diff --git a/netbox/vpn/forms/model_forms.py b/netbox/vpn/forms/model_forms.py index a17ca9a5e8e..0d2e8c01257 100644 --- a/netbox/vpn/forms/model_forms.py +++ b/netbox/vpn/forms/model_forms.py @@ -235,7 +235,7 @@ class TunnelTerminationForm(NetBoxModelForm): selector=True, label=_('Device') ) - termination = DynamicModelChoiceField( + termination_key = DynamicModelChoiceField( queryset=Interface.objects.all(), label=_('Tunnel interface'), query_params={ @@ -252,13 +252,13 @@ class TunnelTerminationForm(NetBoxModelForm): ) fieldsets = ( - FieldSet('tunnel', 'role', 'type', 'parent', 'termination', 'outside_ip', 'tags'), + FieldSet('tunnel', 'role', 'type', 'parent', 'termination_key', 'outside_ip', 'tags'), ) class Meta: model = TunnelTermination fields = [ - 'tunnel', 'role', 'termination', 'outside_ip', 'tags', + 'tunnel', 'role', 'termination_key', 'outside_ip', 'tags', ] def __init__(self, *args, initial=None, **kwargs): @@ -273,8 +273,8 @@ def __init__(self, *args, initial=None, **kwargs): self.fields['parent'].label = _('Virtual Machine') self.fields['parent'].queryset = VirtualMachine.objects.all() self.fields['parent'].widget.attrs['selector'] = 'virtualization.virtualmachine' - self.fields['termination'].queryset = VMInterface.objects.all() - self.fields['termination'].widget.add_query_params({ + self.fields['termination_key'].queryset = VMInterface.objects.all() + self.fields['termination_key'].widget.add_query_params({ 'virtual_machine_id': '$parent', }) self.fields['outside_ip'].widget.add_query_params({ @@ -283,13 +283,13 @@ def __init__(self, *args, initial=None, **kwargs): if self.instance.pk: self.fields['parent'].initial = self.instance.termination.parent_object - self.fields['termination'].initial = self.instance.termination + self.fields['termination_key'].initial = self.instance.termination def clean(self): super().clean() # Set the terminated object - self.instance.termination = self.cleaned_data.get('termination') + self.instance.termination = self.cleaned_data.get('termination_key') class IKEProposalForm(NetBoxModelForm): diff --git a/requirements.txt b/requirements.txt index c3d87e52f07..e3a7c93f867 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django==5.0.9 +Django==5.1.1 django-cors-headers==4.4.0 django-debug-toolbar==4.4.6 django-filter==24.3 From 70989cf44d41462d4490e453a86b561a4494e2e0 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Thu, 26 Sep 2024 11:48:13 -0700 Subject: [PATCH 2/6] 16136 fix migrations --- netbox/extras/migrations/0002_squashed_0059.py | 4 ---- netbox/extras/migrations/0087_squashed_0098.py | 5 ++--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/netbox/extras/migrations/0002_squashed_0059.py b/netbox/extras/migrations/0002_squashed_0059.py index 98bed255a54..a403a0e191f 100644 --- a/netbox/extras/migrations/0002_squashed_0059.py +++ b/netbox/extras/migrations/0002_squashed_0059.py @@ -131,10 +131,6 @@ class Migration(migrations.Migration): name='webhook', unique_together={('payload_url', 'type_create', 'type_update', 'type_delete')}, ), - migrations.AlterIndexTogether( - name='taggeditem', - index_together={('content_type', 'object_id')}, - ), migrations.AlterUniqueTogether( name='exporttemplate', unique_together={('content_type', 'name')}, diff --git a/netbox/extras/migrations/0087_squashed_0098.py b/netbox/extras/migrations/0087_squashed_0098.py index 55f276ecdbb..bbe7f79f57b 100644 --- a/netbox/extras/migrations/0087_squashed_0098.py +++ b/netbox/extras/migrations/0087_squashed_0098.py @@ -98,10 +98,9 @@ class Migration(migrations.Migration): name='object_types', field=models.ManyToManyField(blank=True, related_name='+', to='contenttypes.contenttype'), ), - migrations.RenameIndex( + migrations.AddIndex( model_name='taggeditem', - new_name='extras_tagg_content_717743_idx', - old_fields=('content_type', 'object_id'), + index=models.Index(fields=['content_type', 'object_id'], name='extras_tagg_content_717743_idx'), ), migrations.CreateModel( name='Bookmark', From 90da31e33565260228670dc46a372a6c9df64c02 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 8 Oct 2024 07:44:36 -0700 Subject: [PATCH 3/6] 17476 update remove GFK from fields --- netbox/extras/forms/bulk_import.py | 6 +++--- netbox/ipam/forms/model_forms.py | 18 +++++++++--------- netbox/vpn/forms/model_forms.py | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/netbox/extras/forms/bulk_import.py b/netbox/extras/forms/bulk_import.py index 6e2fe6d6342..258df826435 100644 --- a/netbox/extras/forms/bulk_import.py +++ b/netbox/extras/forms/bulk_import.py @@ -192,7 +192,7 @@ class EventRuleImportForm(NetBoxModelImportForm): label=_('Event types'), help_text=_('The event type(s) which will trigger this rule') ) - action_object_key = forms.CharField( + action_object = forms.CharField( label=_('Action object'), required=True, help_text=_('Webhook name or script as dotted path module.Class') @@ -202,13 +202,13 @@ class Meta: model = EventRule fields = ( 'name', 'description', 'enabled', 'conditions', 'object_types', 'event_types', 'action_type', - 'action_object_key', 'comments', 'tags' + 'comments', 'tags' ) def clean(self): super().clean() - action_object = self.cleaned_data.get('action_object_key') + action_object = self.cleaned_data.get('action_object') action_type = self.cleaned_data.get('action_type') if action_object and action_type: # Webhook diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index fd9dddc2fe9..69321a669f6 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -574,7 +574,7 @@ class VLANGroupForm(NetBoxModelForm): required=False, label=_('Scope type') ) - scope_key = DynamicModelChoiceField( + scope = DynamicModelChoiceField( label=_('Scope'), queryset=Site.objects.none(), # Initial queryset required=False, @@ -585,13 +585,13 @@ class VLANGroupForm(NetBoxModelForm): fieldsets = ( FieldSet('name', 'slug', 'description', 'tags', name=_('VLAN Group')), FieldSet('vid_ranges', name=_('Child VLANs')), - FieldSet('scope_type', 'scope_key', name=_('Scope')), + FieldSet('scope_type', name=_('Scope')), ) class Meta: model = VLANGroup fields = [ - 'name', 'slug', 'description', 'vid_ranges', 'scope_type', 'scope_key', 'tags', + 'name', 'slug', 'description', 'vid_ranges', 'scope_type', 'tags', ] def __init__(self, *args, **kwargs): @@ -599,7 +599,7 @@ def __init__(self, *args, **kwargs): initial = kwargs.get('initial', {}) if instance is not None and instance.scope: - initial['scope_key'] = instance.scope + initial['scope'] = instance.scope kwargs['initial'] = initial super().__init__(*args, **kwargs) @@ -608,15 +608,15 @@ def __init__(self, *args, **kwargs): try: scope_type = ContentType.objects.get(pk=scope_type_id) model = scope_type.model_class() - self.fields['scope_key'].queryset = model.objects.all() - self.fields['scope_key'].widget.attrs['selector'] = model._meta.label_lower - self.fields['scope_key'].disabled = False - self.fields['scope_key'].label = _(bettertitle(model._meta.verbose_name)) + self.fields['scope'].queryset = model.objects.all() + self.fields['scope'].widget.attrs['selector'] = model._meta.label_lower + self.fields['scope'].disabled = False + self.fields['scope'].label = _(bettertitle(model._meta.verbose_name)) except ObjectDoesNotExist: pass if self.instance and scope_type_id != self.instance.scope_type_id: - self.initial['scope_key'] = None + self.initial['scope'] = None def clean(self): super().clean() diff --git a/netbox/vpn/forms/model_forms.py b/netbox/vpn/forms/model_forms.py index 0d2e8c01257..6fee5b01d36 100644 --- a/netbox/vpn/forms/model_forms.py +++ b/netbox/vpn/forms/model_forms.py @@ -235,7 +235,7 @@ class TunnelTerminationForm(NetBoxModelForm): selector=True, label=_('Device') ) - termination_key = DynamicModelChoiceField( + termination = DynamicModelChoiceField( queryset=Interface.objects.all(), label=_('Tunnel interface'), query_params={ @@ -252,13 +252,13 @@ class TunnelTerminationForm(NetBoxModelForm): ) fieldsets = ( - FieldSet('tunnel', 'role', 'type', 'parent', 'termination_key', 'outside_ip', 'tags'), + FieldSet('tunnel', 'role', 'type', 'parent', 'termination_key' 'outside_ip', 'tags'), ) class Meta: model = TunnelTermination fields = [ - 'tunnel', 'role', 'termination_key', 'outside_ip', 'tags', + 'tunnel', 'role', 'outside_ip', 'tags', ] def __init__(self, *args, initial=None, **kwargs): @@ -273,8 +273,8 @@ def __init__(self, *args, initial=None, **kwargs): self.fields['parent'].label = _('Virtual Machine') self.fields['parent'].queryset = VirtualMachine.objects.all() self.fields['parent'].widget.attrs['selector'] = 'virtualization.virtualmachine' - self.fields['termination_key'].queryset = VMInterface.objects.all() - self.fields['termination_key'].widget.add_query_params({ + self.fields['termination'].queryset = VMInterface.objects.all() + self.fields['termination'].widget.add_query_params({ 'virtual_machine_id': '$parent', }) self.fields['outside_ip'].widget.add_query_params({ @@ -283,13 +283,13 @@ def __init__(self, *args, initial=None, **kwargs): if self.instance.pk: self.fields['parent'].initial = self.instance.termination.parent_object - self.fields['termination_key'].initial = self.instance.termination + self.fields['termination'].initial = self.instance.termination def clean(self): super().clean() # Set the terminated object - self.instance.termination = self.cleaned_data.get('termination_key') + self.instance.termination = self.cleaned_data.get('termination') class IKEProposalForm(NetBoxModelForm): From b4bc7af810f45a2ca4f720f19bcbbd4caed377a4 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 8 Oct 2024 09:17:08 -0700 Subject: [PATCH 4/6] 17476 fix --- netbox/ipam/forms/model_forms.py | 2 +- netbox/vpn/forms/model_forms.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index 69321a669f6..156e7c43562 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -585,7 +585,7 @@ class VLANGroupForm(NetBoxModelForm): fieldsets = ( FieldSet('name', 'slug', 'description', 'tags', name=_('VLAN Group')), FieldSet('vid_ranges', name=_('Child VLANs')), - FieldSet('scope_type', name=_('Scope')), + FieldSet('scope_type', 'scope', name=_('Scope')), ) class Meta: diff --git a/netbox/vpn/forms/model_forms.py b/netbox/vpn/forms/model_forms.py index 6fee5b01d36..c6e32b596fd 100644 --- a/netbox/vpn/forms/model_forms.py +++ b/netbox/vpn/forms/model_forms.py @@ -252,7 +252,7 @@ class TunnelTerminationForm(NetBoxModelForm): ) fieldsets = ( - FieldSet('tunnel', 'role', 'type', 'parent', 'termination_key' 'outside_ip', 'tags'), + FieldSet('tunnel', 'role', 'type', 'parent', 'termination' 'outside_ip', 'tags'), ) class Meta: From aca2428ef02a3390118c976a4225bf57e1b99c33 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 8 Oct 2024 09:23:00 -0700 Subject: [PATCH 5/6] 17476 update django to bugfix release --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e3a7c93f867..fca329ccc1a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django==5.1.1 +Django==5.1.2 django-cors-headers==4.4.0 django-debug-toolbar==4.4.6 django-filter==24.3 From 269cd1536badfbc1f108ae06ba64e16fc428c596 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 8 Oct 2024 14:38:35 -0700 Subject: [PATCH 6/6] fix comma --- netbox/vpn/forms/model_forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/vpn/forms/model_forms.py b/netbox/vpn/forms/model_forms.py index c6e32b596fd..dee98afd3ae 100644 --- a/netbox/vpn/forms/model_forms.py +++ b/netbox/vpn/forms/model_forms.py @@ -252,7 +252,7 @@ class TunnelTerminationForm(NetBoxModelForm): ) fieldsets = ( - FieldSet('tunnel', 'role', 'type', 'parent', 'termination' 'outside_ip', 'tags'), + FieldSet('tunnel', 'role', 'type', 'parent', 'termination', 'outside_ip', 'tags'), ) class Meta: