[open-ils-commits] r8606 - trunk/Open-ILS/src/python/oils
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 4 12:14:04 EST 2008
Author: erickson
Date: 2008-02-04 11:45:51 -0500 (Mon, 04 Feb 2008)
New Revision: 8606
Modified:
trunk/Open-ILS/src/python/oils/org.py
Log:
added a min-depth function for a group of orgs, changed some variable names to be more explicit
Modified: trunk/Open-ILS/src/python/oils/org.py
===================================================================
--- trunk/Open-ILS/src/python/oils/org.py 2008-02-04 16:35:21 UTC (rev 8605)
+++ trunk/Open-ILS/src/python/oils/org.py 2008-02-04 16:45:51 UTC (rev 8606)
@@ -98,18 +98,18 @@
return root
@staticmethod
- def get_union_tree(org_list):
- ''' Returns the smallest org tree which encompases all of the orgs in org_list '''
+ def get_union_tree(org_id_list):
+ ''' Returns the smallest org tree which encompases all of the orgs in org_id_list '''
OrgUtil._verify_tree()
- if len(org_list) == 0:
+ if len(org_id_list) == 0:
return None
- main_tree = OrgUtil.get_related_tree(OrgUtil.get_org_unit(org_list[0]))
+ main_tree = OrgUtil.get_related_tree(OrgUtil.get_org_unit(org_id_list[0]))
- if len(org_list) == 1:
+ if len(org_id_list) == 1:
return main_tree
- for org in org_list[1:]:
+ for org in org_id_list[1:]:
node = OrgUtil.get_related_tree(OrgUtil.get_org_unit(org))
main_node = main_tree
@@ -139,6 +139,18 @@
return orglist
@staticmethod
+ def get_min_depth(org_id_list):
+ ''' Returns the minimun depth (highest tree position) of all orgs in the list '''
+ depth = None
+ for org in org_id_list:
+ new_depth = OrgUtil.get_org_type(OrgUtil.get_org_unit(org)).depth()
+ if depth is None:
+ depth = new_depth
+ elif new_depth < depth:
+ depth = new_depth
+ return depth
+
+ @staticmethod
def debug_tree(org_unit, indent=0):
''' Simple function to print the tree of orgs provided '''
for i in range(indent):
More information about the open-ils-commits
mailing list