ES-DOC / esdoc-questionnaire

ES-DOC Questionnaire (webform generator for creating CIM Documents). POC: @allynt
Other
2 stars 1 forks source link

Enumeration fields content gets overwritten in __init__ #464

Closed allynt closed 7 years ago

allynt commented 7 years ago

The symptom is that enumerations for existing models do not have their choices set correctly. This was because it was during the reset() function that those choices were being set and that was only being called for new models. This is now no longer the case.

After a lot of javascript code the choices are now correctly set, as are the initial values.

However, whether or not the field is "open" is getting overwritten (b/c customize seems to be getting called after init).

allynt commented 7 years ago

I can confirm that this is still happening. This is for 2 reasons:

1) the setting of is_open is being done in __init__ based on the proxy, when it should be done in customize based on the customization. This is fairly straightforward to fix.

2) the customization that is associated w/ the underlying realization form does not seem to be the one which is modified by the corresponding customization form. This is confusing.

allynt commented 7 years ago

So I fixed all of the code having to do w/ reason 1 above in dbf54743eea52553fffb08d8bf4ec248e7f82890. As expected, that was fairly straightforward.

But I could not get to the bottom of reason 2 above. Until I discovered that the QRealization.get_default_customization() fn could potentially return the wrong customization b/c a given proxy can occur in multiple places for a complete customization hierarchy (For example, both the SeaIce Realm and the Grid Topic have a property that points to Responsibility; the corresponding proxy therefore has two customizations associated with it). I need to base my selection of customization in that fn on more than just the proxy.

allynt commented 7 years ago

I have written code to find the the "path" of an arbitrary QRealization (ie: the series of steps one takes from the root object to get to it). And I have written code to "walk" that path from the root object and return the desired QRealization. The next step is to take a realization path and apply to a set of customizations...

allynt commented 7 years ago

fd59da136ab8b825c524add4d6d6aa44454f5e5d adds the ability to map "paths" from realizations to customizations. So in QRealization.get_default_customization() I get the path of the realization and use it to return the corresponding customization. Job done.