Skip to content

Commit 32de8a6

Browse files
Merge pull request #1031 from NASA-IMPACT/1030-resolve-0-value-document-type-in-nasa_science
Fix the issues of doctypes having 0 as a doctype
2 parents 16aae30 + 3d11f2e commit 32de8a6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ For each PR made, an entry should be added to this changelog. It should contain
4646
- Used regex to catch any HTML content comming in as an input to form fields
4747
- Called this class within the serializer for necessary fields
4848

49-
49+
- 1030-resolve-0-value-document-type-in-nasa_science
50+
- Description: Around 2000 of the docs coming out of the COSMOS api for nasa_science have a doc type value of 0.
51+
- Changes:
52+
- Added `obj.document_type != 0` as a condition in the `get_document_type` method within the `CuratedURLAPISerializer`
5053

5154
- 1014-add-logs-when-importing-urls-so-we-know-how-many-were-expected-how-many-succeeded-and-how-many-failed
5255
- Description: When URLs of a given collection are imported into COSMOS, a Slack notification is sent. This notification includes the name of the collection imported,count of the existing curated URLs, total URLs count as per the server, URLs successfully imported from the server, delta URLs identified and delta URLs marked for deletion.
@@ -62,7 +65,6 @@ For each PR made, an entry should be added to this changelog. It should contain
6265
- Added a constant `scrollPosition` within `postDocumentTypePatterns` to store the y coordinate postion on the page
6366
- Modified the ajax relaod to navigate to this position upon posting/saving the document type changes.
6467

65-
6668
- 3227-bugfix-title-patterns-selecting-multi-url-pattern-does-nothing
6769
- Description: When selecting options from the match pattern type filter, the system does not filter the results as expected. Instead of displaying only the chosen variety of patterns, it continues to show all patterns.
6870
- Changes:

sde_collections/serializers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,14 @@ def get_tdamm_tag(self, obj):
258258
return categories
259259

260260
def get_document_type(self, obj):
261-
if obj.document_type is not None:
261+
if obj.document_type and obj.document_type not in DocumentTypes.values:
262+
raise ValueError(f"Invalid document type: {obj.document_type}")
263+
elif obj.document_type is not None:
262264
return obj.get_document_type_display()
263265
elif obj.collection.document_type is not None:
264266
return obj.collection.get_document_type_display()
265267
else:
266-
return "Unknown"
268+
raise ValueError("No document type found")
267269

268270
def get_title(self, obj):
269271
return obj.generated_title if obj.generated_title else obj.scraped_title

0 commit comments

Comments
 (0)