From 75991dd5cdc01af9442574027003befb82b3230f Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Sun, 25 Oct 2009 16:51:15 +0000 Subject: [PATCH] 3282: Gramps should only display marriage event with role = family (or primary) svn: r13410 --- src/DataViews/PedigreeView.py | 4 +++- src/DataViews/RelationView.py | 4 +++- src/DisplayModels/_FamilyModel.py | 3 +++ src/plugins/drawreport/Calendar.py | 10 +++++++--- src/plugins/drawreport/StatisticsChart.py | 6 ++++-- src/plugins/graph/GVFamilyLines.py | 4 +++- src/plugins/graph/GVRelGraph.py | 4 +++- src/plugins/textreport/FamilyGroup.py | 4 +++- src/plugins/tool/Verify.py | 4 +++- 9 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/DataViews/PedigreeView.py b/src/DataViews/PedigreeView.py index 1d4691982..3252a4442 100644 --- a/src/DataViews/PedigreeView.py +++ b/src/DataViews/PedigreeView.py @@ -367,7 +367,9 @@ class FormattingHelper(object): text = "" for event_ref in family.get_event_ref_list(): event = self.dbstate.db.get_event_from_handle(event_ref.ref) - if event and event.get_type() == gen.lib.EventType.MARRIAGE: + if event and 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 ): if line_count < 3: return DateHandler.get_date(event) name = str(event.get_type()) diff --git a/src/DataViews/RelationView.py b/src/DataViews/RelationView.py index d98a63e66..99a6155d7 100644 --- a/src/DataViews/RelationView.py +++ b/src/DataViews/RelationView.py @@ -1207,7 +1207,9 @@ class RelationshipView(PageView.PersonNavView): for event_ref in family.get_event_ref_list(): handle = event_ref.ref event = self.dbstate.db.get_event_from_handle(handle) - if event.get_type() == gen.lib.EventType.MARRIAGE: + if event and 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 ): self.write_event_ref(vbox, _('Marriage'), event) value = True return value diff --git a/src/DisplayModels/_FamilyModel.py b/src/DisplayModels/_FamilyModel.py index d90c553d3..a7ef72f0d 100644 --- a/src/DisplayModels/_FamilyModel.py +++ b/src/DisplayModels/_FamilyModel.py @@ -46,6 +46,7 @@ import GrampsLocale import DateHandler from BasicUtils import name_displayer import gen.lib +from gen.lib import EventRoleType import gen.utils from _BaseModel import BaseModel @@ -130,6 +131,8 @@ class FamilyModel(BaseModel): def column_marriage(self, data): erlist = [ gen.lib.EventRef().unserialize(d) for d in data[6] ] + erlist = [x for x in erlist if x.get_role()==EventRoleType.FAMILY or + x.get_role()==EventRoleType.PRIMARY] event = gen.utils.marriage_from_eventref_list(self.db, erlist) if event: return DateHandler.displayer.display(event.date) diff --git a/src/plugins/drawreport/Calendar.py b/src/plugins/drawreport/Calendar.py index 233516822..29e3d72d5 100644 --- a/src/plugins/drawreport/Calendar.py +++ b/src/plugins/drawreport/Calendar.py @@ -319,11 +319,15 @@ class Calendar(Report): for event_ref in fam.get_event_ref_list(): event = self.database.get_event_from_handle(event_ref.ref) if event.type in [gen.lib.EventType.MARRIAGE, - gen.lib.EventType.MARR_ALT]: + gen.lib.EventType.MARR_ALT] and \ + (event_ref.get_role() == gen.lib.EventRoleType.FAMILY or + event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ): are_married = event elif event.type in [gen.lib.EventType.DIVORCE, - gen.lib.EventType.ANNULMENT, - gen.lib.EventType.DIV_FILING]: + gen.lib.EventType.ANNULMENT, + gen.lib.EventType.DIV_FILING] and \ + (event_ref.get_role() == gen.lib.EventRoleType.FAMILY or + event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ): are_married = None if are_married is not None: for event_ref in fam.get_event_ref_list(): diff --git a/src/plugins/drawreport/StatisticsChart.py b/src/plugins/drawreport/StatisticsChart.py index cd16a1ba9..d20c8c17e 100644 --- a/src/plugins/drawreport/StatisticsChart.py +++ b/src/plugins/drawreport/StatisticsChart.py @@ -41,7 +41,7 @@ from TransUtils import sgettext as _ #------------------------------------------------------------------------ # Person and relation types -from gen.lib import Person, FamilyRelType, EventType +from gen.lib import Person, FamilyRelType, EventType, EventRoleType # gender and report type names import BaseDoc from gen.plug import PluginManager @@ -338,7 +338,9 @@ class Extract(object): if int(family.get_relationship()) == FamilyRelType.MARRIED: for event_ref in family.get_event_ref_list(): event = self.db.get_event_from_handle(event_ref.ref) - if event.type == EventType.MARRIAGE: + if event.get_type() == EventType.MARRIAGE and \ + (event_ref.get_role() == EventRoleType.FAMILY or + event_ref.get_role() == EventRoleType.PRIMARY ): marriages.append(event_ref.ref) if marriages: return (person, marriages) diff --git a/src/plugins/graph/GVFamilyLines.py b/src/plugins/graph/GVFamilyLines.py index 4f4139ef8..82752e68f 100644 --- a/src/plugins/graph/GVFamilyLines.py +++ b/src/plugins/graph/GVFamilyLines.py @@ -933,7 +933,9 @@ class FamilyLinesReport(Report): if self._incdates or self._incplaces: for event_ref in family.get_event_ref_list(): event = self._db.get_event_from_handle(event_ref.ref) - if event.get_type() == gen.lib.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 ): # get the wedding date if (event.private and self._incprivate) or not event.private: if self._incdates: diff --git a/src/plugins/graph/GVRelGraph.py b/src/plugins/graph/GVRelGraph.py index 9da15f8b4..6165ba006 100644 --- a/src/plugins/graph/GVRelGraph.py +++ b/src/plugins/graph/GVRelGraph.py @@ -266,7 +266,9 @@ class RelGraphReport(Report): label = "" for event_ref in fam.get_event_ref_list(): event = self.database.get_event_from_handle(event_ref.ref) - if event.type == gen.lib.EventType.MARRIAGE: + if event.type == gen.lib.EventType.MARRIAGE and \ + (event_ref.get_role() == gen.lib.EventRoleType.FAMILY or + event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ): label = self.get_event_string(event) break if self.includeid: diff --git a/src/plugins/textreport/FamilyGroup.py b/src/plugins/textreport/FamilyGroup.py index 463bfc5c1..6ac68c7a5 100644 --- a/src/plugins/textreport/FamilyGroup.py +++ b/src/plugins/textreport/FamilyGroup.py @@ -337,7 +337,9 @@ class FamilyGroup(Report): for event_ref in family_list: if event_ref: event = self.database.get_event_from_handle(event_ref.ref) - if event.get_type() == gen.lib.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 ): m = event break diff --git a/src/plugins/tool/Verify.py b/src/plugins/tool/Verify.py index 776e85559..abc0fec61 100644 --- a/src/plugins/tool/Verify.py +++ b/src/plugins/tool/Verify.py @@ -209,7 +209,9 @@ def get_marriage_date(db,family): return 0 for event_ref in family.get_event_ref_list(): event = find_event(db,event_ref.ref) - if event.get_type() == gen.lib.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 ): date_obj = event.get_date_object() return date_obj.get_sort_value() return 0