Fix popup when no theme present

This commit is contained in:
Florian Mounier
2015-10-08 17:50:23 +02:00
parent ca26454aa0
commit ab8e65924d

View File

@@ -321,11 +321,16 @@ class ThemesList(Route):
themes_dir = os.path.join(
self.application.butterfly_dir, 'themes')
self.set_header('Content-Type', 'application/json')
if os.path.exists(themes_dir):
themes = [
theme
for theme in os.listdir(themes_dir)
if os.path.isdir(os.path.join(themes_dir, theme)) and
not theme.startswith('.')]
else:
themes = []
self.write(tornado.escape.json_encode({
'themes': sorted(
[theme
for theme in os.listdir(themes_dir)
if os.path.isdir(os.path.join(themes_dir, theme)) and
not theme.startswith('.')]),
'themes': sorted(themes),
'dir': themes_dir
}))