3282: Gramps should only display marriage event with role = family (or primary)

svn: r13411
This commit is contained in:
Benny Malengier 2009-10-25 16:52:45 +00:00
parent 14dcf94739
commit cad5461b2d
9 changed files with 32 additions and 11 deletions

View File

@ -370,7 +370,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())

View File

@ -1220,7 +1220,9 @@ class RelationshipView(NavigationView):
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

View File

@ -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 gui.views.treemodels.flatbasemodel import FlatBaseModel
@ -130,6 +131,8 @@ class FamilyModel(FlatBaseModel):
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)

View File

@ -326,11 +326,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():

View File

@ -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
from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle,
FONT_SANS_SERIF, FONT_SERIF,
@ -339,7 +339,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)

View File

@ -934,7 +934,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:

View File

@ -264,7 +264,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:

View File

@ -338,7 +338,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

View File

@ -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