Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/django/api/extended_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,19 @@ def get_facility_and_processing_type_extendfield_value(
is_claim_edit=False
):
if is_claim_edit:
field_value_capitalized = (
[value.capitalize() for value in field_value]
)
field_value_capitalized = []

if isinstance(field_value, list):
field_value_capitalized = (
[value.capitalize() for value in field_value]
)

if isinstance(field_value, str):
separated_vals = field_value.split("|")
field_value_capitalized = (
[value.strip().capitalize() for value in separated_vals]
)

raw_values = '|'.join(field_value_capitalized)
results = get_matched_values(field_value_capitalized, sector)
else:
Expand Down
2 changes: 1 addition & 1 deletion src/django/api/tests/test_facility_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def test_create_claim_with_additional_fields(self):
)
self.assertEqual(
claim.facility_production_types,
["Cutting", "Sewing", "Manufacturing"],
["Cutting", "Sewing"],
)
self.assertEqual(
claim.facility_type,
Expand Down
21 changes: 1 addition & 20 deletions src/django/api/views/facility/facilities_view_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@
facilities_list_parameters,
facilities_create_parameters,
)
from api.facility_type_processing_type import (
get_facility_and_processing_type,
)

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -966,30 +963,14 @@ def claim(self, request, pk=None):
facility_production_types=validated_data.get(
"facility_production_types", []
),
facility_type=validated_data.get("facility_type"),
)

sectors = validated_data.get("sectors")

if sectors and len(sectors) > 0:
facility_claim.sector = sectors

facility_type = validated_data.get("facility_type")

if facility_type:
(_, __, facility_type_value, processing_type_value) = (
get_facility_and_processing_type(
facility_type, sectors,
)
)

if facility_type_value:
facility_claim.facility_type = facility_type_value

if processing_type_value:
facility_claim.facility_production_types.append(
processing_type_value,
)

facility_claim.save()

for file in files:
Expand Down
2 changes: 1 addition & 1 deletion src/react/src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ export const appendFacilityType = (postData, formattedKey, value) => {
}

const extractedValues = value.map(extractSelectValue);
postData.append(formattedKey, extractedValues.join(', '));
postData.append(formattedKey, extractedValues.join('|'));
};

/**
Expand Down
Loading