learning-unlimited / ESP-Website

A website to help manage the logistics of large, short-term educational programs
82 stars 57 forks source link

Adding linked fields to existing customforms results in errors #3762

Open willgearty opened 1 month ago

willgearty commented 1 month ago

Found while testing the python3 PR (although I checked and this also occurs on live sites on SR15): image

This arises when you add a linked field to an existing customform. For some reason the field is not added to the existing responses database, so it errors the next time the responses database is accessed. I've added a stopgap for this: whenever editing an existing customform, these field categories are now disabled (6b677a6). However, really we should figure out (if possible) how to update the responses database to include this new linked field.

willgearty commented 1 month ago

It looks like the issue might be a result of the differences between the column names here: https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/customforms/DynamicModel.py#L260 https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/customforms/DynamicModel.py#L277 and here: https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/customforms/DynamicModel.py#L303

Changing all of these to have _id appeared to work for adding a linked field to an existing form, but it's not clear if this will break existing forms with these fields (or using existing form with these fields as templates for new forms).

Should also check out the discrepancies here: https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/customforms/DynamicForm.py#L136

https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/customforms/DynamicForm.py#L653

willgearty commented 1 month ago

Hmm...I tried changing all of the column names to 'link_%s_id'. I could make a new form and fill it in just fine, but then the responses page was broken. I tried the same with all of the column names as 'link_%s' and ran into the same problem. So it seems like there should be two different names used, but I'm guessing one of them is the wrong one somewhere. For now, the stopgap should be sufficient for SR16.