Fix Contact slug generator script or find a better solution
We generate a slug for Contacts in the Wagtail Admin UI by using a custom script. However, the script is currently broken and is somewhat brittle. Fix the script and/or find a more resilient solution.
The code seems to be working today, perhaps it was a transient bug. However, here are some ideas for improvement:
- only run the code when editing a person, not on other Wagtail edit forms
- add error handling
- consider removing unicode characters by default (research whether to allow unicode in URL slugs as a best practice)
- consider using
constforslug_textin thegenerateAutoslugfunction - unit test the code (both via the Wagtail Admin UI and as generic tests)
I tried again to set the PersonModelAdmin.form_view_extra_js bug got no JS response from Wagtail Admin. I'm not sure what might be the cause, and got no response on StackOverflow:
https://stackoverflow.com/questions/76687506/unable-to-load-custom-js-via-wagtail-modeladmin-form-view-extra-js
Moving this to post-launch since I've repeatedly tried to get it to load only on the Person form page.