Skip to content

Commit 2f18832

Browse files
Merge pull request #1215 from NASA-IMPACT/2889-serialize-the-tdamm-tags
serialzed and changed API structure to fit LRM requirements
2 parents 80fbef3 + f63ece7 commit 2f18832

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ For each PR made, an entry should be added to this changelog. It should contain
1212
- etc.
1313

1414
## Changelog
15+
- 2889-serialize-the-tdamm-tags
16+
- Description: Have TDAMM serialzed in a specific way and exposed via the Curated URLs API to be consumed into SDE Test/Prod
17+
- Changes:
18+
- Changed `get_tdamm_tag` method in the `CuratedURLAPISerializer` to process the TDAMM tags and pass them to the API endpoint
19+
1520
- 960-notifications-add-a-dropdown-with-options-on-the-feedback-form
1621
- Description: Generate an API endpoint and publish all the dropdown options necessary as a list for LRM to consume it.
1722
- Changes:

sde_collections/serializers.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from rest_framework import serializers
22

33
from .models.collection import Collection, ReindexingHistory, WorkflowHistory
4-
from .models.collection_choice_fields import Divisions, DocumentTypes
4+
from .models.collection_choice_fields import Divisions, DocumentTypes, TDAMMTags
55
from .models.delta_patterns import (
66
DeltaDivisionPattern,
77
DeltaDocumentTypePattern,
@@ -235,8 +235,27 @@ class Meta:
235235
)
236236

237237
def get_tdamm_tag(self, obj):
238-
tags = obj.tdamm_tag
239-
return tags if tags is not None else []
238+
empty_categories = {"messengers": [], "objects": [], "signals": []}
239+
if not obj.tdamm_tag or obj.tdamm_tag == ["NOT_TDAMM"]:
240+
return empty_categories
241+
242+
categories = empty_categories.copy()
243+
prefix_mapping = {"MMA_M_": "messengers", "MMA_O_": "objects", "MMA_S_": "signals"}
244+
245+
for tag in obj.tdamm_tag:
246+
if tag == "NOT_TDAMM":
247+
continue
248+
249+
tag_text = dict(TDAMMTags.choices).get(tag)
250+
if not tag_text:
251+
continue
252+
253+
for prefix, category in prefix_mapping.items():
254+
if tag.startswith(prefix):
255+
categories[category].append(tag_text.replace(" - ", "/"))
256+
break
257+
258+
return categories
240259

241260
def get_document_type(self, obj):
242261
if obj.document_type is not None:

0 commit comments

Comments
 (0)