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

Commit

Permalink
Merge pull request #1757 from open-apparel-registry/tw/numeric-custom…
Browse files Browse the repository at this point in the history
…-fields

Fix handling of numeric custom cells in Excel
  • Loading branch information
TaiWilkin committed Mar 21, 2022
2 parents 9797175 + aba120d commit 7c769fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit 7c769fc

Please sign in to comment.