17476 Upgrade to Django 5.1

This commit is contained in:
Arthur Hanson 2024-09-26 09:44:32 -07:00
parent 85396866bc
commit 503e781f48
4 changed files with 20 additions and 20 deletions

View File

@ -192,7 +192,7 @@ class EventRuleImportForm(NetBoxModelImportForm):
label=_('Event types'), label=_('Event types'),
help_text=_('The event type(s) which will trigger this rule') help_text=_('The event type(s) which will trigger this rule')
) )
action_object = forms.CharField( action_object_key = forms.CharField(
label=_('Action object'), label=_('Action object'),
required=True, required=True,
help_text=_('Webhook name or script as dotted path module.Class') help_text=_('Webhook name or script as dotted path module.Class')
@ -202,13 +202,13 @@ class EventRuleImportForm(NetBoxModelImportForm):
model = EventRule model = EventRule
fields = ( fields = (
'name', 'description', 'enabled', 'conditions', 'object_types', 'event_types', 'action_type', 'name', 'description', 'enabled', 'conditions', 'object_types', 'event_types', 'action_type',
'action_object', 'comments', 'tags' 'action_object_key', 'comments', 'tags'
) )
def clean(self): def clean(self):
super().clean() 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') action_type = self.cleaned_data.get('action_type')
if action_object and action_type: if action_object and action_type:
# Webhook # Webhook

View File

@ -574,7 +574,7 @@ class VLANGroupForm(NetBoxModelForm):
required=False, required=False,
label=_('Scope type') label=_('Scope type')
) )
scope = DynamicModelChoiceField( scope_key = DynamicModelChoiceField(
label=_('Scope'), label=_('Scope'),
queryset=Site.objects.none(), # Initial queryset queryset=Site.objects.none(), # Initial queryset
required=False, required=False,
@ -585,13 +585,13 @@ class VLANGroupForm(NetBoxModelForm):
fieldsets = ( fieldsets = (
FieldSet('name', 'slug', 'description', 'tags', name=_('VLAN Group')), FieldSet('name', 'slug', 'description', 'tags', name=_('VLAN Group')),
FieldSet('vid_ranges', name=_('Child VLANs')), FieldSet('vid_ranges', name=_('Child VLANs')),
FieldSet('scope_type', 'scope', name=_('Scope')), FieldSet('scope_type', 'scope_key', name=_('Scope')),
) )
class Meta: class Meta:
model = VLANGroup model = VLANGroup
fields = [ 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): def __init__(self, *args, **kwargs):
@ -599,7 +599,7 @@ class VLANGroupForm(NetBoxModelForm):
initial = kwargs.get('initial', {}) initial = kwargs.get('initial', {})
if instance is not None and instance.scope: if instance is not None and instance.scope:
initial['scope'] = instance.scope initial['scope_key'] = instance.scope
kwargs['initial'] = initial kwargs['initial'] = initial
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -608,15 +608,15 @@ class VLANGroupForm(NetBoxModelForm):
try: try:
scope_type = ContentType.objects.get(pk=scope_type_id) scope_type = ContentType.objects.get(pk=scope_type_id)
model = scope_type.model_class() model = scope_type.model_class()
self.fields['scope'].queryset = model.objects.all() self.fields['scope_key'].queryset = model.objects.all()
self.fields['scope'].widget.attrs['selector'] = model._meta.label_lower self.fields['scope_key'].widget.attrs['selector'] = model._meta.label_lower
self.fields['scope'].disabled = False self.fields['scope_key'].disabled = False
self.fields['scope'].label = _(bettertitle(model._meta.verbose_name)) self.fields['scope_key'].label = _(bettertitle(model._meta.verbose_name))
except ObjectDoesNotExist: except ObjectDoesNotExist:
pass pass
if self.instance and scope_type_id != self.instance.scope_type_id: if self.instance and scope_type_id != self.instance.scope_type_id:
self.initial['scope'] = None self.initial['scope_key'] = None
def clean(self): def clean(self):
super().clean() super().clean()

View File

@ -235,7 +235,7 @@ class TunnelTerminationForm(NetBoxModelForm):
selector=True, selector=True,
label=_('Device') label=_('Device')
) )
termination = DynamicModelChoiceField( termination_key = DynamicModelChoiceField(
queryset=Interface.objects.all(), queryset=Interface.objects.all(),
label=_('Tunnel interface'), label=_('Tunnel interface'),
query_params={ query_params={
@ -252,13 +252,13 @@ class TunnelTerminationForm(NetBoxModelForm):
) )
fieldsets = ( fieldsets = (
FieldSet('tunnel', 'role', 'type', 'parent', 'termination', 'outside_ip', 'tags'), FieldSet('tunnel', 'role', 'type', 'parent', 'termination_key', 'outside_ip', 'tags'),
) )
class Meta: class Meta:
model = TunnelTermination model = TunnelTermination
fields = [ fields = [
'tunnel', 'role', 'termination', 'outside_ip', 'tags', 'tunnel', 'role', 'termination_key', 'outside_ip', 'tags',
] ]
def __init__(self, *args, initial=None, **kwargs): def __init__(self, *args, initial=None, **kwargs):
@ -273,8 +273,8 @@ class TunnelTerminationForm(NetBoxModelForm):
self.fields['parent'].label = _('Virtual Machine') self.fields['parent'].label = _('Virtual Machine')
self.fields['parent'].queryset = VirtualMachine.objects.all() self.fields['parent'].queryset = VirtualMachine.objects.all()
self.fields['parent'].widget.attrs['selector'] = 'virtualization.virtualmachine' self.fields['parent'].widget.attrs['selector'] = 'virtualization.virtualmachine'
self.fields['termination'].queryset = VMInterface.objects.all() self.fields['termination_key'].queryset = VMInterface.objects.all()
self.fields['termination'].widget.add_query_params({ self.fields['termination_key'].widget.add_query_params({
'virtual_machine_id': '$parent', 'virtual_machine_id': '$parent',
}) })
self.fields['outside_ip'].widget.add_query_params({ self.fields['outside_ip'].widget.add_query_params({
@ -283,13 +283,13 @@ class TunnelTerminationForm(NetBoxModelForm):
if self.instance.pk: if self.instance.pk:
self.fields['parent'].initial = self.instance.termination.parent_object 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): def clean(self):
super().clean() super().clean()
# Set the terminated object # Set the terminated object
self.instance.termination = self.cleaned_data.get('termination') self.instance.termination = self.cleaned_data.get('termination_key')
class IKEProposalForm(NetBoxModelForm): class IKEProposalForm(NetBoxModelForm):

View File

@ -1,4 +1,4 @@
Django==5.0.9 Django==5.1.1
django-cors-headers==4.4.0 django-cors-headers==4.4.0
django-debug-toolbar==4.4.6 django-debug-toolbar==4.4.6
django-filter==24.3 django-filter==24.3