mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-04 06:38:16 -06:00
17558 raise validation error if removing choice from choiceset that is currently used
This commit is contained in:
parent
983032189a
commit
b59ae0fd93
@ -823,8 +823,12 @@ class CustomFieldChoiceSet(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel
|
|||||||
raise ValidationError(_("Must define base or extra choices."))
|
raise ValidationError(_("Must define base or extra choices."))
|
||||||
|
|
||||||
# check if removing any used choices
|
# check if removing any used choices
|
||||||
|
if self._original_extra_choices:
|
||||||
|
original_choices = new_choices = []
|
||||||
original_choices = [obj[1] for obj in self._original_extra_choices]
|
original_choices = [obj[1] for obj in self._original_extra_choices]
|
||||||
|
if self.extra_choices:
|
||||||
new_choices = [obj[1] for obj in self.extra_choices]
|
new_choices = [obj[1] for obj in self.extra_choices]
|
||||||
|
|
||||||
diff_choices = list(set(original_choices) - set(new_choices))
|
diff_choices = list(set(original_choices) - set(new_choices))
|
||||||
if diff_choices:
|
if diff_choices:
|
||||||
# CustomFields using this ChoiceSet
|
# CustomFields using this ChoiceSet
|
||||||
|
Loading…
Reference in New Issue
Block a user