Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issues of doctypes having 0 as a doctype #1031

Merged
merged 9 commits into from
Feb 28, 2025
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ For each PR made, an entry should be added to this changelog. It should contain
- Used regex to catch any HTML content comming in as an input to form fields
- Called this class within the serializer for necessary fields


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

- 1014-add-logs-when-importing-urls-so-we-know-how-many-were-expected-how-many-succeeded-and-how-many-failed
- 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.
Expand All @@ -62,7 +65,6 @@ For each PR made, an entry should be added to this changelog. It should contain
- Added a constant `scrollPosition` within `postDocumentTypePatterns` to store the y coordinate postion on the page
- Modified the ajax relaod to navigate to this position upon posting/saving the document type changes.


- 3227-bugfix-title-patterns-selecting-multi-url-pattern-does-nothing
- 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.
- Changes:
Expand Down
6 changes: 4 additions & 2 deletions sde_collections/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,14 @@ def get_tdamm_tag(self, obj):
return categories

def get_document_type(self, obj):
if obj.document_type is not None:
if obj.document_type and obj.document_type not in DocumentTypes.values:
raise ValueError(f"Invalid document type: {obj.document_type}")
elif obj.document_type is not None:
return obj.get_document_type_display()
elif obj.collection.document_type is not None:
return obj.collection.get_document_type_display()
else:
return "Unknown"
raise ValueError("No document type found")

def get_title(self, obj):
return obj.generated_title if obj.generated_title else obj.scraped_title
Expand Down