Skip to content

Commit

Permalink
Merge branch 'staging' into 189537/PDU-targeting
Browse files Browse the repository at this point in the history
  • Loading branch information
pkujawa authored Aug 20, 2024
2 parents 8bd5bd1 + 956e5a2 commit 21c24ac
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _get_form_field_for_value(self, flexible_attribute: FlexibleAttribute) -> fo
elif flexible_attribute.pdu_data.subtype == PeriodicFieldData.DECIMAL:
return forms.DecimalField(required=False)
elif flexible_attribute.pdu_data.subtype == PeriodicFieldData.BOOL:
return StrictBooleanField(required=False)
return forms.FloatField(required=False)
elif flexible_attribute.pdu_data.subtype == PeriodicFieldData.DATE:
return forms.DateField(required=False)
raise ValidationError(f"Invalid subtype for field {flexible_attribute.name}")
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_import_data_decimal(self) -> None:
self.assertEqual(periodic_data_update_upload.status, PeriodicDataUpdateUpload.Status.SUCCESSFUL)
self.assertEqual(periodic_data_update_upload.error_message, None)
self.individual.refresh_from_db()
self.assertEqual(self.individual.flex_fields[flexible_attribute.name]["1"]["value"], "20.456")
self.assertEqual(self.individual.flex_fields[flexible_attribute.name]["1"]["value"], 20.456)
self.assertEqual(self.individual.flex_fields[flexible_attribute.name]["1"]["collection_date"], "2021-05-02")

def test_import_data_boolean(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def handle_pdu_fields(self, row: list[Any], header: list[Any], individual: Pendi
collection_date_cell = row_dict.get(column_collection_date)
subtype = flexible_attribute.pdu_data.subtype
handle_subtype = handle_subtype_mapping[subtype]
value = handle_subtype(value_cell)
value = handle_subtype(value_cell, is_flex_field=True)
if not collection_date_cell.value:
collection_date = self.registration_data_import.created_at.date()
else:
Expand Down

0 comments on commit 21c24ac

Please sign in to comment.