Skip to content

Commit 629fa0f

Browse files
authored
Merge pull request #120 from okfn/486-mover-helpers
add get_iati_file_type_label
2 parents 52946eb + f732509 commit 629fa0f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

ckanext/iati_generator/assets/css/main.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,11 @@ details[open] summary {
9090

9191
.missing-files-list {
9292
margin-top: 4px;
93-
}
93+
}
94+
95+
.iati-file-type-label {
96+
margin-left: 8px;
97+
color: #666;
98+
font-size: 0.9em;
99+
font-style: italic;
100+
}

ckanext/iati_generator/helpers.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,3 +832,18 @@ def normalize_iati_errors(error_dict: Any, package_id: Optional[str] = None) ->
832832
"items": deduped,
833833
"raw": [raw_formatted],
834834
}
835+
836+
837+
def get_iati_file_type_label(value):
838+
"""
839+
Converts an iati_file_type value to its human-readable label.
840+
For example: '100' -> 'Organization Main File'
841+
"""
842+
if not value:
843+
return ''
844+
845+
for choice in iati_file_types():
846+
if str(choice.get('value')) == str(value):
847+
return choice.get('label', '')
848+
849+
return str(value)

ckanext/iati_generator/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ def get_helpers(self):
7373
"iati_file_type": h.iati_file_types,
7474
"iati_namespaces": h.iati_namespaces,
7575
"has_final_iati_resource": h.has_final_iati_resource,
76+
"get_iati_file_type_label": h.get_iati_file_type_label,
7677
}

0 commit comments

Comments
 (0)