[Mpuls-commits] r5603 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Nov 18 11:58:58 CET 2011


Author: ludwig
Date: 2011-11-18 11:58:55 +0100 (Fri, 18 Nov 2011)
New Revision: 5603

Modified:
   base/trunk/mpulsweb/lib/export.py
Log:
Issue 2620: In the XLS export set id always on the id of the case and replace
the master_id with an id of the rg.


Modified: base/trunk/mpulsweb/lib/export.py
===================================================================
--- base/trunk/mpulsweb/lib/export.py	2011-11-18 10:41:22 UTC (rev 5602)
+++ base/trunk/mpulsweb/lib/export.py	2011-11-18 10:58:55 UTC (rev 5603)
@@ -133,7 +133,7 @@
         for name, columns in table_columns.iteritems():
             extra_columns = ["id"]
             if name in repeat_groups:
-                extra_columns.append("master_id")
+                extra_columns.append(name)
             self.tables[name] = self.table_factory(titles[name],
                                                    extra_columns + columns)
             for column_name in columns:
@@ -145,20 +145,20 @@
         """Fill the tables with the contents of the ElementTree tree."""
         self.repeat_group_ids = itertools.count()
         for case_id, case in enumerate(tree.getiterator('master')):
-            self.fill_from_node(case, case_id)
+            self.fill_from_node(case, case_id, case_id)
 
-    def fill_from_node(self, node, node_id, parent_id=None):
-        rows = defaultdict(lambda: dict(id=node_id))
+    def fill_from_node(self, node, node_id, case_id, parent_name=None):
+        rows = defaultdict(lambda: dict(id=case_id))
+        
+        if parent_name is not None:
+            rows[node.tag][parent_name] = node_id
 
-        if parent_id is not None:
-            rows[node.tag]["master_id"] = parent_id
-
         for child in node.getchildren():
             name = child.tag
             nc = self.meta_tree.findByName(name)
             if isinstance(nc, RepeatNode):
                 self.fill_from_node(child, self.repeat_group_ids.next(),
-                                    node_id)
+                                    case_id, name)
             else:
                 table_name = self.field_name_to_table_name.get(name)
                 if table_name is not None:



More information about the Mpuls-commits mailing list