This is all happening inside a mako template, so you could just compute the set of flags in python, and then just use it as a string in js.

Instead of adding the `get_flags` function to javascript, you could add it to python, and then just use the line `group = ' + '.join(waffle.all_flags()) or 'Control Group'`

Although I would also consider leaving the Control group simply as the empty string.