westernfriend.org icon indicating copy to clipboard operation
westernfriend.org copied to clipboard

Fix Contact slug generator script or find a better solution

Open brylie opened this issue 2 years ago • 3 comments

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.

brylie avatar Jul 13 '23 09:07 brylie

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 const for slug_text in the generateAutoslug function
  • unit test the code (both via the Wagtail Admin UI and as generic tests)

brylie avatar Jul 14 '23 09:07 brylie

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

brylie avatar Jul 25 '23 15:07 brylie

Moving this to post-launch since I've repeatedly tried to get it to load only on the Person form page.

brylie avatar Jul 28 '23 16:07 brylie