mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-05 00:47:17 +02:00
cleanup
This commit is contained in:
@@ -42,16 +42,10 @@ class ScriptModuleSerializer(ValidatedModelSerializer):
|
|||||||
|
|
||||||
# For multipart requests, nested serializer fields (data_source, data_file) are
|
# For multipart requests, nested serializer fields (data_source, data_file) are
|
||||||
# silently dropped by DRF's HTML parser, so also check initial_data for raw values.
|
# silently dropped by DRF's HTML parser, so also check initial_data for raw values.
|
||||||
# These checks must run before super().validate() calls full_clean(), which would
|
|
||||||
# otherwise surface confusing unique-constraint errors for empty file_path values.
|
|
||||||
has_data_file = data.get('data_file') or self.initial_data.get('data_file')
|
has_data_file = data.get('data_file') or self.initial_data.get('data_file')
|
||||||
has_data_source = data.get('data_source') or self.initial_data.get('data_source')
|
has_data_source = data.get('data_source') or self.initial_data.get('data_source')
|
||||||
|
|
||||||
if upload_file and has_data_file:
|
if upload_file and (has_data_file or has_data_source):
|
||||||
raise serializers.ValidationError(
|
|
||||||
_("Cannot upload a file and sync from an existing file.")
|
|
||||||
)
|
|
||||||
if upload_file and has_data_source:
|
|
||||||
raise serializers.ValidationError(
|
raise serializers.ValidationError(
|
||||||
_("Cannot upload a file and sync from a data source.")
|
_("Cannot upload a file and sync from a data source.")
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user