Skip to content

Commit 3ff6aad

Browse files
made necessary changes
1 parent fcd054d commit 3ff6aad

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sde_collections/serializers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,14 @@ def get_tdamm_tag(self, obj):
239239
return tags if tags is not None else []
240240

241241
def get_document_type(self, obj):
242-
if obj.document_type and obj.document_type != 0:
242+
if obj.document_type and obj.document_type not in DocumentTypes.values:
243+
raise ValueError(f"Invalid document type: {obj.document_type}")
244+
elif obj.document_type is not None:
243245
return obj.get_document_type_display()
244246
elif obj.collection.document_type is not None:
245247
return obj.collection.get_document_type_display()
246248
else:
247-
return "Unknown"
249+
raise ValueError("No document type found")
248250

249251
def get_title(self, obj):
250252
return obj.generated_title if obj.generated_title else obj.scraped_title

0 commit comments

Comments
 (0)