Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Fix handling of numeric custom cells in Excel #1757

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Hide contributor details in embed downloads [#1742](https://github.com/open-apparel-registry/open-apparel-registry/pull/1742)
- Wrap long filenames in My Lists page [#1756](https://github.com/open-apparel-registry/open-apparel-registry/pull/1756)
- Fix handling of numeric custom fields [#1757](https://github.com/open-apparel-registry/open-apparel-registry/pull/1757)

### Security

Expand Down
12 changes: 10 additions & 2 deletions src/django/api/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,19 @@ def get_csv_values(csv_data):
return values


def try_parse_int_from_float(value):
try:
return str(int(float(value)))
except ValueError:
return value


def get_single_contributor_field_values(item, fields):
data = parse_raw_data(item.raw_data)
for f in fields:
value = data.get(f['column_name'], None)
if value is not None:
f['value'] = value
f['value'] = try_parse_int_from_float(value)
return fields


Expand All @@ -62,7 +69,8 @@ def get_list_contributor_field_values(item, fields):
for f in fields:
if f['column_name'] in list_fields:
index = list_fields.index(f['column_name'])
f['value'] = data_values[index]
f['value'] = try_parse_int_from_float(data_values[index])

return fields


Expand Down