Browse Source

[#69] Added the code to add the relations to all the superiors in a hierarchy

Roland Haroutiounian 9 years ago
parent
commit
6a4a7af931
2 changed files with 7 additions and 1 deletions
  1. 6
    0
      leobject/datasources/ledatasourcesql.py
  2. 1
    1
      leobject/leobject.py

+ 6
- 0
leobject/datasources/ledatasourcesql.py View File

@@ -423,6 +423,12 @@ class LeDataSourceSQL(DummyDatasource):
423 423
             cur.execute('SELECT last_insert_id()')
424 424
             relation_id, = cur.fetchone()
425 425
 
426
+        if nature == 'parent':
427
+            parent_superiors = lesup.superiors()
428
+            for superior in parent_superiors:
429
+                depth = depth - 1 if depth is not None else 1
430
+                self.add_relation(lesup=superior.lodel_id, lesub=lesub.lodel_id, nature='parent', depth=depth, rank=rank)
431
+
426 432
         return relation_id
427 433
 
428 434
     ## @brief Fetch a superiors list ordered by depth for a LeType

+ 1
- 1
leobject/leobject.py View File

@@ -304,7 +304,7 @@ class _LeObject(object):
304 304
         if leo_is_sup:
305 305
             return cls._datasource.get_subordinates(leo, nature)
306 306
         else:
307
-            return cls._datasource.get_superior(leo, nature)
307
+            return cls._datasource.get_superiors(leo, nature)
308 308
     
309 309
     ## @brief Prepare a field_list
310 310
     # @param field_list list : List of string representing fields

Loading…
Cancel
Save