codeforamerica / chime

A city-focused content management system
http://chimecms.org/
BSD 3-Clause "New" or "Revised" License
35 stars 12 forks source link

possible to get multiple flash messages on redirect #452

Open tmaybe opened 9 years ago

tmaybe commented 9 years ago

If you load a page that redirects (for example, loading /edit/blah will auto-redirect to /edit/blah/ with trailing slash) it's possible to see multiple identical flash messages at the top of the page. This is happening with the new conflict warning flashes.

It can be solved by using view_functions.flash_unique() instead of flash() but it may make sense to figure out a more catch-all solution.

wpietri commented 9 years ago

Would the more catch-all solution here be to make it so that calling flash() does the equivalent of flash_unique()? I know how I'd accomplish that in other languages, but python's import rituals are still mysterious to me, so I'd have to research a bit.

tmaybe commented 9 years ago

flash_unique()show the flash if it's not an exact duplicate – and flash_only()show the flash if there aren't any other flashes – aren't the best solutions either. There are situations where the content of a flash can change (like the time that has passed since something happened) but I still want to make sure I'm only showing one of them at a time, without having to worry about blocking or being blocked by flashes from other processes. I was thinking of writing a front-end that saved a third parameter to flashes that I could check for this purpose.

That said, I think we're eventually going to have to replace Flask's built-in flash functionality, because we want to be able to add interactive elements to them.