Create extended field values for processing/facility type #1616
Conversation
These will be used when processing facilities that have processing and/or facility types specified. Refs #1583
04f3e9f
to
0d89101
Compare
0d89101
to
89adabb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, clear implementation. I made a suggestion that I think is required to mate the expectations that submitting a value for either field sets values on both.
if (raw_data.get('processing_type') and | ||
raw_data.get('facility_type') is None): | ||
raw_data['facility_type'] = raw_data['processing_type'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may want to do this in reverse as well since each facility type is also included as a processing type. Better to err on the side of having the facility show up when searching either field for a particular value.
if (raw_data.get('facility_type') and
raw_data.get('processing_type') is None):
raw_data['processing_type'] = raw_data['facility_type']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh good point. I'll switch this up.
src/django/api/extended_fields.py
Outdated
for field in RAW_DATA_FIELDS: | ||
if field in fields: | ||
field_value = values[fields.index(field)] | ||
create_extendedfield(field, field_value, item, contributor) | ||
|
||
# Add a facility_type extended field if the user only | ||
# submitted a processing_type | ||
if ((field == 'processing_type') and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may want to do this in reverse as well since each facility type is also included as a processing type. Better to err on the side of having the facility show up when searching either field for a particular value.
if ((field == 'facility_type') and
'processing_type' not in fields):
create_extendedfield('processing_type', field_value, item,
contributor)
89adabb
to
19c05e0
Compare
The field values are used as look-up values in the facility/processing type matching function. Single and multiple types are handled from both the API endpoint and when processing a CSV. If any of the submitted types are unabled to be matched, a parsing error is returned for that facility. Refs #1583
The structure of the processing/facility type values are more complex than the other extended fields and special handling will need to be implemented before the values can be displayed in the front-end. Refs #1583
19c05e0
to
99edd75
Compare
Overview
When the
processing_type
orfacility_type
fields are included with facilities submitted via the API or CSV, the field values are matched to facility/processing values in the taxonomy using the matching function. Users can specify single or multiple values. If any of the submitted types are unable to be matched, a parsing error is returned for that facility.Connects #1583
Demo
Single value submitted for facility type via API
Multiple values submitted for processing type via CSV
Invalid value is submitted via CSV
Invalid value is submitted via API
Notes
Currently, processing/facility type values are not displayed on the front-end. We may need a follow-up card for this, although there are some cards that may cover this (#1592? #1613?)
Testing Instructions
./scripts/update
to apply the included migrationproduct_type
withprocessing_type
orfacility_type
.{ facility_type: "raw material processing or production" }
{ processing_type: ["cutting", "assembly"] }
{ processing_type: "sdfjasdkjfsakdfjsf" }
{ processing_type: "cutting" }
"raw material processing or production"
"cutting"|"assembly"
"dfsadfasdfsdaf"
"cutting"
Checklist
fixup!
commits have been squashed