* src/ReportBase/_ReportUtils: Factor out common code into get_birth_or_fallback() and get_death_or_fallback()
* src/DataViews/_PedigreeView.py: Use get_birth/death_or_fallback() * src/DataViews/_RelationView.py: Use get_birth/death_or_fallback() * src/DisplayModels/_PeopleModel.py: Fix EventRoleType call svn: r7669
This commit is contained in:
parent
2906476bc1
commit
2157a1fbdc
@ -2,6 +2,12 @@
|
|||||||
* src/RelLib/_Person.py (set_birth_ref,set_death_ref): Dont fail if setting
|
* src/RelLib/_Person.py (set_birth_ref,set_death_ref): Dont fail if setting
|
||||||
to None (which is what Check.py does).
|
to None (which is what Check.py does).
|
||||||
* src/plugins/TestcaseGenerator.py: Make it work again + some enhancements
|
* src/plugins/TestcaseGenerator.py: Make it work again + some enhancements
|
||||||
|
* src/ReportBase/_ReportUtils: Factor out common code into
|
||||||
|
get_birth_or_fallback() and get_death_or_fallback()
|
||||||
|
* src/DataViews/_PedigreeView.py: Use get_birth/death_or_fallback()
|
||||||
|
* src/DataViews/_RelationView.py: Use get_birth/death_or_fallback()
|
||||||
|
* src/DisplayModels/_PeopleModel.py: Fix EventRoleType call
|
||||||
|
|
||||||
|
|
||||||
2006-11-21 Brian Matherly <brian@gramps-project.org>
|
2006-11-21 Brian Matherly <brian@gramps-project.org>
|
||||||
* src/plugins/DetDescendantReport.py: 0000558: Print only primary events
|
* src/plugins/DetDescendantReport.py: 0000558: Print only primary events
|
||||||
|
@ -391,35 +391,8 @@ class FormattingHelper:
|
|||||||
if line_count < 3:
|
if line_count < 3:
|
||||||
return name
|
return name
|
||||||
|
|
||||||
birth_ref = person.get_birth_ref()
|
birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, person)
|
||||||
birth = None
|
if birth and use_markup and birth.get_type() != RelLib.EventType.BIRTH:
|
||||||
birth_fallback = False
|
|
||||||
if birth_ref:
|
|
||||||
birth = self.dbstate.db.get_event_from_handle(birth_ref.ref)
|
|
||||||
else:
|
|
||||||
for event_ref in person.get_event_ref_list():
|
|
||||||
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
|
||||||
if event.get_type() in [RelLib.EventType.CHRISTEN, RelLib.EventType.BAPTISM] and\
|
|
||||||
event_ref.get_role() == RelLib.EventRoleType.PRIMARY:
|
|
||||||
birth = event
|
|
||||||
birth_fallback = True
|
|
||||||
break
|
|
||||||
|
|
||||||
death_ref = person.get_death_ref()
|
|
||||||
death = None
|
|
||||||
death_fallback = False
|
|
||||||
if death_ref:
|
|
||||||
death = self.dbstate.db.get_event_from_handle(death_ref.ref)
|
|
||||||
else:
|
|
||||||
for event_ref in person.get_event_ref_list():
|
|
||||||
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
|
||||||
if event.get_type() in [RelLib.EventType.BURIAL, RelLib.EventType.CREMATION] and\
|
|
||||||
event_ref.get_role() == RelLib.EventRoleType.PRIMARY:
|
|
||||||
death = event
|
|
||||||
death_fallback = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if birth and birth_fallback and use_markup:
|
|
||||||
bdate = "<i>%s</i>" % DateHandler.get_date(birth)
|
bdate = "<i>%s</i>" % DateHandler.get_date(birth)
|
||||||
bplace = "<i>%s</i>" % self.get_place_name(birth.get_place_handle())
|
bplace = "<i>%s</i>" % self.get_place_name(birth.get_place_handle())
|
||||||
elif birth:
|
elif birth:
|
||||||
@ -428,7 +401,8 @@ class FormattingHelper:
|
|||||||
else:
|
else:
|
||||||
bdate = ""
|
bdate = ""
|
||||||
bplace = ""
|
bplace = ""
|
||||||
if death and death_fallback and use_markup:
|
death = ReportUtils.get_death_or_fallback(self.dbstate.db, person)
|
||||||
|
if death and use_markup and death.get_type() != RelLib.EventType.DEATH:
|
||||||
ddate = "<i>%s</i>" % DateHandler.get_date(death)
|
ddate = "<i>%s</i>" % DateHandler.get_date(death)
|
||||||
dplace = "<i>%s</i>" % self.get_place_name(death.get_place_handle())
|
dplace = "<i>%s</i>" % self.get_place_name(death.get_place_handle())
|
||||||
elif death:
|
elif death:
|
||||||
|
@ -487,48 +487,22 @@ class RelationshipView(PageView.PersonNavView):
|
|||||||
2, 3, 0, 1, yoptions=0)
|
2, 3, 0, 1, yoptions=0)
|
||||||
|
|
||||||
# Birth event.
|
# Birth event.
|
||||||
birth_ref = person.get_birth_ref()
|
birth = ReportUtils.get_birth_or_fallback(self.dbstate.db,person)
|
||||||
birth_title = _('Birth')
|
if birth:
|
||||||
birth = None
|
birth_title = birth.get_type()
|
||||||
if birth_ref:
|
|
||||||
birth = self.dbstate.db.get_event_from_handle(birth_ref.ref)
|
|
||||||
else:
|
else:
|
||||||
for event_ref in person.get_event_ref_list():
|
birth_title = None
|
||||||
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
|
||||||
if event.get_type() == RelLib.EventType.CHRISTEN and\
|
|
||||||
event_ref.get_role() == RelLib.EventRoleType.PRIMARY:
|
|
||||||
birth_title = _('Christening')
|
|
||||||
birth = event
|
|
||||||
break
|
|
||||||
if event.get_type() == RelLib.EventType.BAPTISM and\
|
|
||||||
event_ref.get_role() == RelLib.EventRoleType.PRIMARY:
|
|
||||||
birth_title = _('Baptism')
|
|
||||||
birth = event
|
|
||||||
break
|
|
||||||
|
|
||||||
subtbl.attach(GrampsWidgets.BasicLabel("%s:" % birth_title),
|
subtbl.attach(GrampsWidgets.BasicLabel("%s:" % birth_title),
|
||||||
1, 2, 1, 2, xoptions=gtk.FILL, yoptions=0)
|
1, 2, 1, 2, xoptions=gtk.FILL, yoptions=0)
|
||||||
subtbl.attach(GrampsWidgets.BasicLabel(self.format_event(birth)),
|
subtbl.attach(GrampsWidgets.BasicLabel(self.format_event(birth)),
|
||||||
2, 3, 1, 2, yoptions=0)
|
2, 3, 1, 2, yoptions=0)
|
||||||
|
|
||||||
death_ref = person.get_death_ref()
|
death = ReportUtils.get_death_or_fallback(self.dbstate.db,person)
|
||||||
death_title = _('Death')
|
if death:
|
||||||
death = None
|
death_title = death.get_type()
|
||||||
if death_ref:
|
|
||||||
death = self.dbstate.db.get_event_from_handle(death_ref.ref)
|
|
||||||
else:
|
else:
|
||||||
for event_ref in person.get_event_ref_list():
|
death_title = None
|
||||||
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
|
||||||
if event.get_type() == RelLib.EventType.BURIAL and\
|
|
||||||
event_ref.get_role() == RelLib.EventRoleType.PRIMARY:
|
|
||||||
death_title = _('Burial')
|
|
||||||
death = event
|
|
||||||
break
|
|
||||||
if event.get_type() == RelLib.EventType.CREMATION and\
|
|
||||||
event_ref.get_role() == RelLib.EventRoleType.PRIMARY:
|
|
||||||
death_title = _('Cremation')
|
|
||||||
death = event
|
|
||||||
break
|
|
||||||
|
|
||||||
subtbl.attach(GrampsWidgets.BasicLabel("%s:" % death_title),
|
subtbl.attach(GrampsWidgets.BasicLabel("%s:" % death_title),
|
||||||
1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0)
|
1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0)
|
||||||
@ -790,41 +764,16 @@ class RelationshipView(PageView.PersonNavView):
|
|||||||
if not child:
|
if not child:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
birth_ref = child.get_birth_ref()
|
birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, child)
|
||||||
birth = None
|
if birth and birth.get_type != RelLib.EventType.BIRTH:
|
||||||
birth_fallback = False
|
|
||||||
if birth_ref:
|
|
||||||
birth = self.dbstate.db.get_event_from_handle(birth_ref.ref)
|
|
||||||
else:
|
|
||||||
for event_ref in child.get_event_ref_list():
|
|
||||||
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
|
||||||
if event.get_type() in [RelLib.EventType.CHRISTEN, RelLib.EventType.BAPTISM] and\
|
|
||||||
event_ref.get_role() == RelLib.EventRoleType.PRIMARY:
|
|
||||||
birth = event
|
|
||||||
birth_fallback = True
|
|
||||||
break
|
|
||||||
|
|
||||||
death_ref = child.get_death_ref()
|
|
||||||
death = None
|
|
||||||
death_fallback = False
|
|
||||||
if death_ref:
|
|
||||||
death = self.dbstate.db.get_event_from_handle(death_ref.ref)
|
|
||||||
else:
|
|
||||||
for event_ref in child.get_event_ref_list():
|
|
||||||
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
|
||||||
if event.get_type() in [RelLib.EventType.BURIAL, RelLib.EventType.CREMATION] and\
|
|
||||||
event_ref.get_role() == RelLib.EventRoleType.PRIMARY:
|
|
||||||
death = event
|
|
||||||
death_fallback = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if birth and birth_fallback:
|
|
||||||
bdate = "<i>%s</i>" % DateHandler.get_date(birth)
|
bdate = "<i>%s</i>" % DateHandler.get_date(birth)
|
||||||
elif birth:
|
elif birth:
|
||||||
bdate = DateHandler.get_date(birth)
|
bdate = DateHandler.get_date(birth)
|
||||||
else:
|
else:
|
||||||
bdate = ""
|
bdate = ""
|
||||||
if death and death_fallback:
|
|
||||||
|
death = ReportUtils.get_death_or_fallback(self.dbstate.db, child)
|
||||||
|
if death and death.get_type != RelLib.EventType.DEATH:
|
||||||
ddate = "<i>%s</i>" % DateHandler.get_date(death)
|
ddate = "<i>%s</i>" % DateHandler.get_date(death)
|
||||||
elif death:
|
elif death:
|
||||||
ddate = DateHandler.get_date(death)
|
ddate = DateHandler.get_date(death)
|
||||||
|
@ -455,7 +455,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
etype = event.get_type()
|
etype = event.get_type()
|
||||||
date_str = DateHandler.get_date(event)
|
date_str = DateHandler.get_date(event)
|
||||||
if (etype in [EventType.BAPTISM, EventType.CHRISTEN]
|
if (etype in [EventType.BAPTISM, EventType.CHRISTEN]
|
||||||
and er.get_role() == RelLib.EventRoleType.PRIMARY
|
and er.get_role() == EventRoleType.PRIMARY
|
||||||
and date_str != ""):
|
and date_str != ""):
|
||||||
return "<i>" + cgi.escape(date_str) + "</i>"
|
return "<i>" + cgi.escape(date_str) + "</i>"
|
||||||
|
|
||||||
@ -482,7 +482,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
etype = event.get_type()
|
etype = event.get_type()
|
||||||
date_str = DateHandler.get_date(event)
|
date_str = DateHandler.get_date(event)
|
||||||
if (etype in [EventType.BURIAL, EventType.CREMATION]
|
if (etype in [EventType.BURIAL, EventType.CREMATION]
|
||||||
and er.get_role() == RelLib.EventRoleType.PRIMARY
|
and er.get_role() == EventRoleType.PRIMARY
|
||||||
and date_str != ""):
|
and date_str != ""):
|
||||||
return "<i>" + cgi.escape(date_str) + "</i>"
|
return "<i>" + cgi.escape(date_str) + "</i>"
|
||||||
|
|
||||||
@ -512,7 +512,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
event = self.db.get_event_from_handle(er.ref)
|
event = self.db.get_event_from_handle(er.ref)
|
||||||
etype = event.get_type()
|
etype = event.get_type()
|
||||||
if etype in [EventType.BAPTISM, EventType.CHRISTEN]\
|
if etype in [EventType.BAPTISM, EventType.CHRISTEN]\
|
||||||
and er.get_role() == RelLib.EventRoleType.PRIMARY:
|
and er.get_role() == EventRoleType.PRIMARY:
|
||||||
place_handle = event.get_place_handle()
|
place_handle = event.get_place_handle()
|
||||||
if place_handle:
|
if place_handle:
|
||||||
place = self.db.get_place_from_handle(place_handle)
|
place = self.db.get_place_from_handle(place_handle)
|
||||||
@ -546,7 +546,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
event = self.db.get_event_from_handle(er.ref)
|
event = self.db.get_event_from_handle(er.ref)
|
||||||
etype = event.get_type()
|
etype = event.get_type()
|
||||||
if etype in [EventType.BURIAL, EventType.CREMATION]\
|
if etype in [EventType.BURIAL, EventType.CREMATION]\
|
||||||
and er.get_role() == RelLib.EventRoleType.PRIMARY:
|
and er.get_role() == EventRoleType.PRIMARY:
|
||||||
place_handle = event.get_place_handle()
|
place_handle = event.get_place_handle()
|
||||||
if place_handle:
|
if place_handle:
|
||||||
place = self.db.get_place_from_handle(place_handle)
|
place = self.db.get_place_from_handle(place_handle)
|
||||||
|
@ -2141,6 +2141,27 @@ def list_person_str(database,person,empty_date="",empty_place=""):
|
|||||||
text = ""
|
text = ""
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
def get_birth_or_fallback(database,person):
|
||||||
|
birth_ref = person.get_birth_ref()
|
||||||
|
if birth_ref: # regular birth found
|
||||||
|
return database.get_event_from_handle(birth_ref.ref)
|
||||||
|
# now search the event list for fallbacks
|
||||||
|
for event_ref in person.get_primary_event_ref_list():
|
||||||
|
event = database.get_event_from_handle(event_ref.ref)
|
||||||
|
if event.get_type() in [RelLib.EventType.CHRISTEN, RelLib.EventType.BAPTISM]:
|
||||||
|
return event
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_death_or_fallback(database,person):
|
||||||
|
birth_ref = person.get_death_ref()
|
||||||
|
if birth_ref: # regular death found
|
||||||
|
return database.get_event_from_handle(birth_ref.ref)
|
||||||
|
# now search the event list for fallbacks
|
||||||
|
for event_ref in person.get_primary_event_ref_list():
|
||||||
|
event = database.get_event_from_handle(event_ref.ref)
|
||||||
|
if event.get_type() in [RelLib.EventType.BURIAL, RelLib.EventType.CREMATION]:
|
||||||
|
return event
|
||||||
|
return None
|
||||||
|
|
||||||
def old_calc_age(database,person):
|
def old_calc_age(database,person):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user