Remove db requirement from constructor and add get_plural_relationship_string to relationship class.

svn: r8831
This commit is contained in:
Brian Matherly
2007-08-18 13:31:50 +00:00
parent 32f3f2c129
commit 7a72009239
20 changed files with 309 additions and 149 deletions

View File

@ -120,8 +120,8 @@ _niece_level = [ "", "sobrina", "sobrina nieta", "sobrina bisnieta", ]
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self,db):
Relationship.RelationshipCalculator.__init__(self,db)
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_male_cousin(self,level):
if level<len(_level_name_male):
@ -250,7 +250,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return "%d-ésima sobrina nieta" % (level-1)
def get_relationship(self,orig_person,other_person):
def get_relationship(self,db,orig_person,other_person):
"""
returns a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
@ -262,13 +262,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(orig_person,other_person)
is_spouse = self.is_spouse(db,orig_person,other_person)
if is_spouse:
return (is_spouse,[])
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
(firstRel,secondRel,common) = \
self.get_relationship_distance(db,orig_person,other_person)
if type(common) == types.StringType or type(common) == types.UnicodeType:
if type(common) == types.StringType or \
type(common) == types.UnicodeType:
return (common,[])
elif common:
person_handle = common[0]