Make event groups consistent with event type menu

This commit is contained in:
Nick Hall 2014-01-23 19:22:44 +00:00
parent 9ecc665625
commit 39aa5a5f81

View File

@ -71,78 +71,17 @@ def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
SECTION_CATEGORY = _("Sections") # only used in add_menu_options (so no _T_)
# headers for the sections
FACTS = _T_("Individual Facts")
EDUCATION = EventType.xml_str(EventType(EventType.EDUCATION))
CENSUS = EventType.xml_str(EventType(EventType.CENSUS))
ELECTED = EventType.xml_str(EventType(EventType.ELECTED))
MED_INFO = EventType.xml_str(EventType(EventType.MED_INFO))
MILITARY_SERV = EventType.xml_str(EventType(EventType.MILITARY_SERV))
NOB_TITLE = EventType.xml_str(EventType(EventType.NOB_TITLE))
OCCUPATION = EventType.xml_str(EventType(EventType.OCCUPATION))
PROPERTY = EventType.xml_str(EventType(EventType.PROPERTY))
RESIDENCE = EventType.xml_str(EventType(EventType.RESIDENCE))
FAMILY = _T_("Family")
CUSTOM = _T_("Custom")
SECTION_LIST = [FACTS, CENSUS, EDUCATION, ELECTED, MED_INFO,
MILITARY_SERV, NOB_TITLE, OCCUPATION, PROPERTY,
RESIDENCE, CUSTOM]
#Grouping of eventtypes in sections
GROUP_DICT = {FACTS: [EventType.ADOPT,
EventType.ADULT_CHRISTEN,
EventType.BAPTISM,
EventType.BAR_MITZVAH,
EventType.BAS_MITZVAH,
EventType.BIRTH,
EventType.BURIAL,
EventType.CAUSE_DEATH,
EventType.CHRISTEN,
EventType.CONFIRMATION,
EventType.CREMATION,
EventType.DEATH,
EventType.EMIGRATION,
EventType.FIRST_COMMUN,
EventType.IMMIGRATION,
EventType.NATURALIZATION,
EventType.ORDINATION,
EventType.PROBATE,
EventType.RELIGION,
EventType.RETIREMENT,
EventType.UNKNOWN,
EventType.WILL],
FAMILY: [EventType.ANNULMENT,
EventType.BLESS,
EventType.ENGAGEMENT,
EventType.DIVORCE,
EventType.DIV_FILING,
EventType.MARRIAGE,
EventType.MARR_ALT,
EventType.MARR_BANNS,
EventType.MARR_CONTR,
EventType.MARR_LIC,
EventType.MARR_SETTL,
EventType.NUM_MARRIAGES],
EDUCATION: [EventType.DEGREE,
EventType.EDUCATION,
EventType.GRADUATION],
CENSUS: [EventType.CENSUS],
ELECTED: [EventType.ELECTED],
MED_INFO: [EventType.MED_INFO],
MILITARY_SERV: [EventType.MILITARY_SERV],
NOB_TITLE: [EventType.NOB_TITLE],
OCCUPATION: [EventType.OCCUPATION],
PROPERTY: [EventType.PROPERTY],
RESIDENCE: [EventType.RESIDENCE],
CUSTOM: [EventType.CUSTOM],
}
#Construct type to group map
# Construct section list and type to group map
SECTION_LIST = []
TYPE2GROUP = {}
for event_group, type_list in GROUP_DICT.items():
for event_group, type_list in EventType().get_menu():
SECTION_LIST.append(event_group)
for event_type in type_list:
TYPE2GROUP[event_type] = event_group
SECTION_LIST.append(CUSTOM)
TYPE2GROUP[EventType.CUSTOM] = CUSTOM
#------------------------------------------------------------------------
#
@ -203,11 +142,10 @@ class IndivCompleteReport(Report):
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
def write_fact(self, event_ref, event, event_group):
def write_fact(self, event_ref, event, show_type=True):
"""
Writes a single event.
"""
group_size = len(GROUP_DICT[event_group])
role = event_ref.get_role()
description = event.get_description()
@ -219,7 +157,7 @@ class IndivCompleteReport(Report):
place_handle).get_title()
date_place = combine(self._('%s in %s. '), '%s. ', date, place)
if group_size != 1 or event_group == CUSTOM:
if show_type:
# Groups with more than one type
column_1 = self._(self._get_type(event.get_type()))
if role not in (EventRoleType.PRIMARY, EventRoleType.FAMILY):
@ -456,7 +394,7 @@ class IndivCompleteReport(Report):
event_ref_list = family.get_event_ref_list()
for event_ref, event in self.get_event_list(event_ref_list):
self.write_fact(event_ref, event, FAMILY)
self.write_fact(event_ref, event)
child_ref_list = family.get_child_ref_list()
if len(child_ref_list):
@ -511,7 +449,7 @@ class IndivCompleteReport(Report):
self.doc.end_row()
for event_ref, event in self.get_event_list(event_ref_list):
self.write_fact(event_ref, event, event_group)
self.write_fact(event_ref, event)
self.doc.end_table()
self.doc.start_paragraph("IDS-Normal")
@ -531,7 +469,7 @@ class IndivCompleteReport(Report):
event = self.database.get_event_from_handle(event_ref.ref)
group = TYPE2GROUP[event.get_type().value]
if _(group) not in self.section_list:
group = FACTS
group = SECTION_LIST[0]
event_dict[group].append(event_ref)
# Write separate event group sections
@ -742,7 +680,7 @@ class IndivCompleteOptions(MenuReportOptions):
opt = BooleanListOption(_("Event groups"))
opt.set_help(_("Check if a separate section is required."))
for section in SECTION_LIST:
if section != FACTS:
if section != SECTION_LIST[0]:
opt.add_button(_(section), True)
menu.add_option(category_name, "sections", opt)