NaevaTheCat / corroboree

0 stars 0 forks source link

ClusterableModel validation fix, e.g. max family members #29

Open NaevaTheCat opened 1 month ago

NaevaTheCat commented 1 month ago

Didn't work during demo. Investigate

NaevaTheCat commented 6 days ago

This seems to be an issue with the clusterablemodel stuff. There isn't a relationship to the parent defined at the time of validation, so it can't look backwards via that in validation, hence the skip:

      if not hasattr(self, 'primary_shareholder'):
            return

I've tried moving this to the member validation but that doesn't work. It's possible a custom form is the answer or something? I don't know if there can be a hardcoded number.

This has consequences for all custom validation, so maybe it would be better to move away from clusterablemodels for now? Or maybe moving the 'children' off them will fix it? Wasted a lot of time so far, am asking for help

NaevaTheCat commented 1 day ago

12 minutes ago Ahhh. I think having the clean in the model makes it execute too late to not save the extra folks. 11 minutes ago So do I need to make custom admin views and not leverage wagtails wonderful santity saving magic to do this? 11 minutes ago https://docs.wagtail.org/en/stable/advanced_topics/customisation/page_editing_interface.html#custom-edit-handler-forms 10 minutes ago I note, it does try to execute the family_member validation stuff. Hence the attr check, as it executes ?before? saving the parent 10 minutes ago No but you do need to put the clean method in your own form subclass