mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 09:28:38 -06:00
Fixes #4702: Catch IntegrityError exception when adding a non-unique secret
This commit is contained in:
parent
d23b18beb5
commit
edf15532d2
@ -1,5 +1,13 @@
|
|||||||
# NetBox v2.8
|
# NetBox v2.8
|
||||||
|
|
||||||
|
## v2.8.6 (FUTURE)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* [#4702](https://github.com/netbox-community/netbox/issues/4702) - Catch IntegrityError exception when adding a non-unique secret
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## v2.8.5 (2020-05-26)
|
## v2.8.5 (2020-05-26)
|
||||||
|
|
||||||
**Note:** The minimum required version of PostgreSQL is now 9.6.
|
**Note:** The minimum required version of PostgreSQL is now 9.6.
|
||||||
|
@ -115,6 +115,16 @@ class SecretForm(BootstrapMixin, CustomFieldModelForm):
|
|||||||
'plaintext2': "The two given plaintext values do not match. Please check your input."
|
'plaintext2': "The two given plaintext values do not match. Please check your input."
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Validate uniqueness
|
||||||
|
if Secret.objects.filter(
|
||||||
|
device=self.cleaned_data['device'],
|
||||||
|
role=self.cleaned_data['role'],
|
||||||
|
name=self.cleaned_data['name']
|
||||||
|
).exists():
|
||||||
|
raise forms.ValidationError(
|
||||||
|
"Each secret assigned to a device must have a unique combination of role and name"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SecretCSVForm(CustomFieldModelCSVForm):
|
class SecretCSVForm(CustomFieldModelCSVForm):
|
||||||
device = CSVModelChoiceField(
|
device = CSVModelChoiceField(
|
||||||
|
Loading…
Reference in New Issue
Block a user