From 285e23303c6220b290a19721b51da48ae9822608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Thu, 29 Oct 2009 11:44:09 +0000 Subject: [PATCH] 3278: [Records plugin] Mariage calculation should only work with event_role=Family or primary svn: r13455 --- src/plugins/Records.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/plugins/Records.py b/src/plugins/Records.py index 86ed1b8eb..9f86958bd 100644 --- a/src/plugins/Records.py +++ b/src/plugins/Records.py @@ -34,7 +34,8 @@ from TransUtils import sgettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from gen.lib import ChildRefType, Date, EventType, Name +import gen.lib +from gen.lib import ChildRefType, Date, EventType, Name, EventRoleType import BaseDoc from BasicUtils import name_displayer from DataViews import register, Gramplet @@ -142,9 +143,13 @@ def _find_records(db, filter, callname): divorce_date = None for event_ref in family.get_event_ref_list(): event = db.get_event_from_handle(event_ref.ref) - if event.get_type() == EventType.MARRIAGE: + if event.get_type() == gen.lib.EventType.MARRIAGE and \ + (event_ref.get_role() == gen.lib.EventRoleType.FAMILY or + event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ): marriage_date = event.get_date_object() - elif event.get_type() == EventType.DIVORCE: + elif event.get_type() == gen.lib.EventType.DIVORCE and \ + (event_ref.get_role() == gen.lib.EventRoleType.FAMILY or + event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ): divorce_date = event.get_date_object() if _good_date(marriage_date): @@ -226,9 +231,13 @@ def _find_records(db, filter, callname): divorce_date = None for event_ref in family.get_event_ref_list(): event = db.get_event_from_handle(event_ref.ref) - if event.get_type() == EventType.MARRIAGE: + if event.get_type() == gen.lib.EventType.MARRIAGE and \ + (event_ref.get_role() == gen.lib.EventRoleType.FAMILY or + event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ): marriage_date = event.get_date_object() - elif event.get_type() == EventType.DIVORCE: + if event and event.get_type() == gen.lib.EventType.DIVORCE and \ + (event_ref.get_role() == gen.lib.EventRoleType.FAMILY or + event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ): divorce_date = event.get_date_object() father_death_date = _find_death_date(db, father)