]> git.parisson.com Git - telemeta.git/commitdiff
fix new csv keys
authorGuillaume Pellerin <yomguy@parisson.com>
Tue, 13 Jan 2015 00:22:05 +0000 (01:22 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Tue, 13 Jan 2015 00:22:05 +0000 (01:22 +0100)
telemeta/views/playlist.py

index 17c86ad3b3202237ef3214a83ccb1eba87255738..0068e0df21474883a5e19bfc8bbc20dcb5d1d9c9 100644 (file)
@@ -111,9 +111,9 @@ class PlaylistView(object):
                     elements.append(collection)
 
         if elements:
-            element = elements[0].to_dict_with_more()
-            tags = element.keys()
-            for e in elements:
+            tags = []
+            element_dicts = [e.to_dict_with_more() for e in elements]
+            for e in element_dicts:
                 for key in e.keys():
                     if not key in tags:
                         tags.append(key)
@@ -125,11 +125,13 @@ class PlaylistView(object):
             tags.insert(0, 'code')
             writer.writerow(tags)
 
-            for element in elements:
+            for element in element_dicts:
                 data = []
-                element = element.to_dict_with_more()
                 for tag in tags:
-                    data.append(element[tag])
+                    if tag in element.keys():
+                        data.append(element[tag])
+                    else:
+                        data.append('')
                 writer.writerow(data)
 
         return response