|
1 | 1 | from rest_framework import serializers
|
2 | 2 |
|
3 | 3 | 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 |
5 | 5 | from .models.delta_patterns import (
|
6 | 6 | DeltaDivisionPattern,
|
7 | 7 | DeltaDocumentTypePattern,
|
@@ -235,8 +235,27 @@ class Meta:
|
235 | 235 | )
|
236 | 236 |
|
237 | 237 | 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 |
240 | 259 |
|
241 | 260 | def get_document_type(self, obj):
|
242 | 261 | if obj.document_type is not None:
|
|
0 commit comments