[importexport] Make badge.visible optional
PEP8
PEP8
Avoid bare ampersand in templates, and simplify query construction