django-formidable icon indicating copy to clipboard operation
django-formidable copied to clipboard

`ContextFormSerializer` doesn't use `contextualize`

Open brunobord opened this issue 7 years ago • 0 comments
trafficstars

The ContextFormSerializer view returns a contextualized form using the DRF serializers & such. On the other hand, the contextualize function returns a contextualized form that analyses the fields and the conditions, etc.

They DON'T return the same result, which is misleading, because we would expect them to work the same way, and the integrator wouldn't understand why the "ValidateViewFromSchema" is using a difference schema for validation... BTW, this view is the only location where the contextualize function is called.

refs:

  • ContextFormSerializer: https://github.com/peopledoc/django-formidable/blob/master/formidable/serializers/forms.py#L135-L147
  • contextualize: https://github.com/peopledoc/django-formidable/blob/master/formidable/serializers/forms.py#L201-L209
  • ValidateViewFromSchema: https://github.com/peopledoc/django-formidable/blob/master/formidable/views.py#L323

We need to standardize this: I understand that the implementation using DRF Serializers would return less items from the DB, because they filter out the unneeded fields, etc ; but on the other hand, the contextualize function is far easier to read, and it looks like it's a naive but efficient implementation of contextualization decorrelated from the actual model implementation. If some day, we switch to a simple key/JSON value storage, we won't have to reimplement contextualization, the function won't change.

brunobord avatar Mar 06 '18 17:03 brunobord