mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Fixes #7654: Fix assignment of members to virtual chassis with initial position of zero
This commit is contained in:
parent
726e4df54b
commit
3cb8c5db28
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
* [#7564](https://github.com/netbox-community/netbox/issues/7564) - Fix assignment of members to virtual chassis with initial position of zero
|
||||||
* [#7701](https://github.com/netbox-community/netbox/issues/7701) - Fix conflation of assigned IP status & role in interface tables
|
* [#7701](https://github.com/netbox-community/netbox/issues/7701) - Fix conflation of assigned IP status & role in interface tables
|
||||||
* [#7741](https://github.com/netbox-community/netbox/issues/7741) - Fix 404 when attaching multiple images in succession
|
* [#7741](https://github.com/netbox-community/netbox/issues/7741) - Fix 404 when attaching multiple images in succession
|
||||||
* [#7752](https://github.com/netbox-community/netbox/issues/7752) - Fix minimum version check under Python v3.10
|
* [#7752](https://github.com/netbox-community/netbox/issues/7752) - Fix minimum version check under Python v3.10
|
||||||
|
@ -117,12 +117,18 @@ class VirtualChassisCreateForm(BootstrapMixin, CustomFieldModelForm):
|
|||||||
'name', 'domain', 'region', 'site_group', 'site', 'rack', 'members', 'initial_position', 'tags',
|
'name', 'domain', 'region', 'site_group', 'site', 'rack', 'members', 'initial_position', 'tags',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
if self.cleaned_data['members'] and self.cleaned_data['initial_position'] is None:
|
||||||
|
raise forms.ValidationError({
|
||||||
|
'initial_position': "A position must be specified for the first VC member."
|
||||||
|
})
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
instance = super().save(*args, **kwargs)
|
instance = super().save(*args, **kwargs)
|
||||||
|
|
||||||
# Assign VC members
|
# Assign VC members
|
||||||
if instance.pk:
|
if instance.pk and self.cleaned_data['members']:
|
||||||
initial_position = self.cleaned_data.get('initial_position') or 1
|
initial_position = self.cleaned_data.get('initial_position', 1)
|
||||||
for i, member in enumerate(self.cleaned_data['members'], start=initial_position):
|
for i, member in enumerate(self.cleaned_data['members'], start=initial_position):
|
||||||
member.virtual_chassis = instance
|
member.virtual_chassis = instance
|
||||||
member.vc_position = i
|
member.vc_position = i
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
<a href="{{ vc_member.get_absolute_url }}">{{ vc_member }}</a>
|
<a href="{{ vc_member.get_absolute_url }}">{{ vc_member }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% badge vc_member.vc_position %}
|
{% badge vc_member.vc_position show_empty=True %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if object.master == vc_member %}
|
{% if object.master == vc_member %}
|
||||||
|
Loading…
Reference in New Issue
Block a user