fixes #2137 date type cutsom fields with webhooks

This coerses all date type custom field values to strings. This is due to a problem
with serializing datetime objects.
This commit is contained in:
John Anderson 2018-07-21 15:17:20 -04:00
parent beac676a6e
commit 65c2668478
2 changed files with 4 additions and 1 deletions

View File

@ -103,6 +103,9 @@ class CustomFieldModelSerializer(ValidatedModelSerializer):
for cfv in instance.custom_field_values.all():
if cfv.field.type == CF_TYPE_SELECT:
custom_fields[cfv.field.name] = CustomFieldChoiceSerializer(cfv.value).data
elif cfv.field.type == CF_TYPE_DATE:
# convert datetime object to str
custom_fields[cfv.field.name] = str(cfv.value)
else:
custom_fields[cfv.field.name] = cfv.value
instance.custom_fields = custom_fields

View File

@ -177,7 +177,7 @@ class CustomFieldAPITest(HttpStatusMixin, APITestCase):
(self.cf_text, 'Test string'),
(self.cf_integer, 1234),
(self.cf_boolean, True),
(self.cf_date, date(2016, 6, 23)),
(self.cf_date, "2016-06-23"),
(self.cf_url, 'http://example.com/'),
(self.cf_select, self.cf_select_choice1.pk),
]