mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-01 07:03:22 +02:00
Revert "Align ManagedFileForm validation with API serializer rules"
This reverts commit f0ac7c3bd2.
This commit is contained in:
@@ -107,18 +107,10 @@ class ManagedFileForm(SyncedDataMixin, NetBoxModelForm):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
upload_file = self.cleaned_data.get('upload_file')
|
if self.cleaned_data.get('upload_file') and self.cleaned_data.get('data_file'):
|
||||||
data_source = self.cleaned_data.get('data_source')
|
|
||||||
data_file = self.cleaned_data.get('data_file')
|
|
||||||
|
|
||||||
if upload_file and data_file:
|
|
||||||
raise forms.ValidationError(_("Cannot upload a file and sync from an existing file"))
|
raise forms.ValidationError(_("Cannot upload a file and sync from an existing file"))
|
||||||
if upload_file and data_source:
|
if not self.cleaned_data.get('upload_file') and not self.cleaned_data.get('data_file'):
|
||||||
raise forms.ValidationError(_("Cannot upload a file and sync from a data source."))
|
raise forms.ValidationError(_("Must upload a file or select a data file to sync"))
|
||||||
if data_source and not data_file:
|
|
||||||
raise forms.ValidationError(_("A data file must be specified when syncing from a data source."))
|
|
||||||
if not upload_file and not data_file:
|
|
||||||
raise forms.ValidationError(_("Must upload a file or select a data source and data file to sync."))
|
|
||||||
|
|
||||||
return self.cleaned_data
|
return self.cleaned_data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user