From 1a5776913512233760412666601b9b65f828b875 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 23 Jan 2007 01:51:33 +0000 Subject: [PATCH] * src/ReportBase/_ReportUtils.py: Add function "get_address_str" * src/plugins/DetDescendantReport.py: Add addresses (0000791) * src/plugins/DetAncestralReport.py: Add addresses (0000791) * src/plugins/IndivComplete.py: Add addresses (0000791) * src/plugins/NarrativeWeb.py: use "get_address_str" * src/plugins/FamilyGroup.py: use "get_address_str" svn: r7956 --- ChangeLog | 8 +++++++ src/ReportBase/_ReportUtils.py | 29 +++++++++++++++++++++++++ src/plugins/DetAncestralReport.py | 30 +++++++++++++++++++++++++ src/plugins/DetDescendantReport.py | 30 +++++++++++++++++++++++++ src/plugins/FamilyGroup.py | 3 +-- src/plugins/IndivComplete.py | 35 ++++++++++++++++++++++++++++++ src/plugins/NarrativeWeb.py | 3 +-- 7 files changed, 134 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 252543698..8e65df53a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-01-22 Brian Matherly + * src/ReportBase/_ReportUtils.py: Add function "get_address_str" + * src/plugins/DetDescendantReport.py: Add addresses (0000791) + * src/plugins/DetAncestralReport.py: Add addresses (0000791) + * src/plugins/IndivComplete.py: Add addresses (0000791) + * src/plugins/NarrativeWeb.py: use "get_address_str" + * src/plugins/FamilyGroup.py: use "get_address_str" + 2007-01-22 Don Allingham * src/ViewManager.py: import of gramps package * src/ArgHandler.py: import of gramps package diff --git a/src/ReportBase/_ReportUtils.py b/src/ReportBase/_ReportUtils.py index c5a52006a..c3e16f4c6 100644 --- a/src/ReportBase/_ReportUtils.py +++ b/src/ReportBase/_ReportUtils.py @@ -2285,3 +2285,32 @@ def get_person_mark(db,person): key = "%s (%s - %s)" % (name,birth,death) return BaseDoc.IndexMark( key, BaseDoc.INDEX_TYPE_ALP ) + +#------------------------------------------------------------------------- +# +# Address String +# +#------------------------------------------------------------------------- +def get_address_str(addr): + """ + Returns a string that combines the elements of an addres + + @param addr: the GRAMPS address instance + """ + str = "" + elems = [ addr.get_street(), + addr.get_city(), + addr.get_county(), + addr.get_state(), + addr.get_country(), + addr.get_postal_code(), + addr.get_phone() ] + + for info in elems: + if info: + if str == "": + str = info + else: + str = "%s, %s" % (str,info) + return str + diff --git a/src/plugins/DetAncestralReport.py b/src/plugins/DetAncestralReport.py index a92aeece3..234216821 100644 --- a/src/plugins/DetAncestralReport.py +++ b/src/plugins/DetAncestralReport.py @@ -113,6 +113,7 @@ class DetAncestorReport(Report): self.addImages = options_class.handler.options_dict['incphotos'] self.includeNames = options_class.handler.options_dict['incnames'] self.includeEvents = options_class.handler.options_dict['incevents'] + self.includeAddr = options_class.handler.options_dict['incaddresses'] self.includeSources= options_class.handler.options_dict['incsources'] self.gen_handles = {} @@ -309,6 +310,25 @@ class DetAncestorReport(Report): first = 0 self.write_event(event_ref) + + if self.includeAddr: + for addr in person.get_address_list(): + if first: + self.doc.start_paragraph('DAR-MoreHeader') + self.doc.write_text(_('More about %(person_name)s:') % { + 'person_name' : name }) + self.doc.end_paragraph() + first = False + self.doc.start_paragraph('DAR-MoreDetails') + + text = ReportUtils.get_address_str(addr) + date = DateHandler.get_date(addr) + self.doc.write_text(_('Address: ')) + if date: + self.doc.write_text( '%s, ' % date ) + self.doc.write_text( text ) + self.doc.write_text( self.endnotes(addr) ) + self.doc.end_paragraph() return 0 # Not duplicate person @@ -678,6 +698,7 @@ class DetAncestorOptions(ReportOptions): 'incphotos' : 0, 'incnames' : 0, 'incevents' : 0, + 'incaddresses' : 0, 'incsources' : 0, } self.options_help = { @@ -717,6 +738,9 @@ class DetAncestorOptions(ReportOptions): 'incevents' : ("=0/1","Whether to include events.", ["Do not include events","Include events"], True), + 'incaddresses': ("=0/1","Whether to include addresses.", + ["Do not include addresses","Include addresses"], + True), 'incsources' : ("=0/1","Whether to include source references.", ["Do not include sources","Include sources"], True), @@ -885,6 +909,10 @@ class DetAncestorOptions(ReportOptions): # Print events self.include_events_option = gtk.CheckButton(_("Include events")) self.include_events_option.set_active(self.options_dict['incevents']) + + # Print addresses + self.include_addresses_option = gtk.CheckButton(_("Include addresses")) + self.include_addresses_option.set_active(self.options_dict['incaddresses']) # Print sources self.include_sources_option = gtk.CheckButton(_("Include sources")) @@ -904,6 +932,7 @@ class DetAncestorOptions(ReportOptions): dialog.add_frame_option(_('Include'),'',self.include_notes_option) dialog.add_frame_option(_('Include'),'',self.include_names_option) dialog.add_frame_option(_('Include'),'',self.include_events_option) + dialog.add_frame_option(_('Include'),'',self.include_addresses_option) dialog.add_frame_option(_('Include'),'',self.include_sources_option) dialog.add_frame_option(_('Missing information'),'',self.place_option) dialog.add_frame_option(_('Missing information'),'',self.date_option) @@ -925,6 +954,7 @@ class DetAncestorOptions(ReportOptions): self.options_dict['incphotos'] = int(self.image_option.get_active()) self.options_dict['incnames'] = int(self.include_names_option.get_active()) self.options_dict['incevents'] = int(self.include_events_option.get_active()) + self.options_dict['incaddresses'] = int(self.include_addresses_option.get_active()) self.options_dict['incsources'] = int(self.include_sources_option.get_active()) #------------------------------------------------------------------------ diff --git a/src/plugins/DetDescendantReport.py b/src/plugins/DetDescendantReport.py index d3a1f76b1..d1c020fa0 100644 --- a/src/plugins/DetDescendantReport.py +++ b/src/plugins/DetDescendantReport.py @@ -116,6 +116,7 @@ class DetDescendantReport(Report): self.addImages = options_class.handler.options_dict['incphotos'] self.includeNames = options_class.handler.options_dict['incnames'] self.includeEvents = options_class.handler.options_dict['incevents'] + self.includeAddr = options_class.handler.options_dict['incaddresses'] self.includeSources= options_class.handler.options_dict['incsources'] self.includeMates = options_class.handler.options_dict['incmates'] @@ -337,6 +338,25 @@ class DetDescendantReport(Report): first = 0 self.write_event(event_ref) + + if self.includeAddr: + for addr in person.get_address_list(): + if first: + self.doc.start_paragraph('DDR-MoreHeader') + self.doc.write_text(_('More about %(person_name)s:') % { + 'person_name' : name }) + self.doc.end_paragraph() + first = False + self.doc.start_paragraph('DDR-MoreDetails') + + text = ReportUtils.get_address_str(addr) + date = DateHandler.get_date(addr) + self.doc.write_text(_('Address: ')) + if date: + self.doc.write_text( '%s, ' % date ) + self.doc.write_text( text ) + self.doc.write_text( self.endnotes(addr) ) + self.doc.end_paragraph() return 0 # Not duplicate person @@ -705,6 +725,7 @@ class DetDescendantOptions(ReportOptions): 'incphotos' : 0, 'incnames' : 0, 'incevents' : 0, + 'incaddresses' : 0, 'incsources' : 0, 'incmates' : 1, } @@ -745,6 +766,9 @@ class DetDescendantOptions(ReportOptions): 'incevents' : ("=0/1","Whether to include events.", ["Do not include events","Include events"], True), + 'incaddresses': ("=0/1","Whether to include addresses.", + ["Do not include addresses","Include addresses"], + True), 'incsources' : ("=0/1","Whether to include source references.", ["Do not include sources","Include sources"], True), @@ -916,6 +940,10 @@ class DetDescendantOptions(ReportOptions): # Print events self.include_events_option = gtk.CheckButton(_("Include events")) self.include_events_option.set_active(self.options_dict['incevents']) + + # Print addresses + self.include_addresses_option = gtk.CheckButton(_("Include addresses")) + self.include_addresses_option.set_active(self.options_dict['incaddresses']) # Print sources self.include_sources_option = gtk.CheckButton(_("Include sources")) @@ -939,6 +967,7 @@ class DetDescendantOptions(ReportOptions): dialog.add_frame_option(_('Include'),'',self.include_notes_option) dialog.add_frame_option(_('Include'),'',self.include_names_option) dialog.add_frame_option(_('Include'),'',self.include_events_option) + dialog.add_frame_option(_('Include'),'',self.include_addresses_option) dialog.add_frame_option(_('Include'),'',self.include_sources_option) dialog.add_frame_option(_('Include'),'',self.include_spouses_option) dialog.add_frame_option(_('Missing information'),'',self.place_option) @@ -961,6 +990,7 @@ class DetDescendantOptions(ReportOptions): self.options_dict['incphotos'] = int(self.image_option.get_active()) self.options_dict['incnames'] = int(self.include_names_option.get_active()) self.options_dict['incevents'] = int(self.include_events_option.get_active()) + self.options_dict['incaddresses'] = int(self.include_addresses_option.get_active()) self.options_dict['incsources'] = int(self.include_sources_option.get_active()) self.options_dict['incmates'] = int(self.include_spouses_option.get_active()) diff --git a/src/plugins/FamilyGroup.py b/src/plugins/FamilyGroup.py index 962dba17a..636b08254 100644 --- a/src/plugins/FamilyGroup.py +++ b/src/plugins/FamilyGroup.py @@ -338,8 +338,7 @@ class FamilyGroup(Report): if self.incParAddr: addrlist = person.get_address_list()[:] for addr in addrlist: - location = "%s %s %s %s" % (addr.get_street(),addr.get_city(), - addr.get_state(),addr.get_country()) + location = ReportUtils.get_address_str(addr) date = DateHandler.get_date( addr ) self.doc.start_row() diff --git a/src/plugins/IndivComplete.py b/src/plugins/IndivComplete.py index ab3875c30..8ffe9792a 100644 --- a/src/plugins/IndivComplete.py +++ b/src/plugins/IndivComplete.py @@ -280,6 +280,40 @@ class IndivCompleteReport(Report): self.doc.start_paragraph('IDS-Normal') self.doc.end_paragraph() + def write_addresses(self): + + alist = self.start_person.get_address_list() + + if len(alist) == 0: + return + + self.doc.start_table("addresses","IDS-IndTable") + self.doc.start_row() + self.doc.start_cell("IDS-TableHead",2) + self.doc.start_paragraph("IDS-TableTitle") + self.doc.write_text(_("Addresses")) + self.doc.end_paragraph() + self.doc.end_cell() + self.doc.end_row() + + for addr in alist: + text = ReportUtils.get_address_str(addr) + date = DateHandler.get_date(addr) + + self.doc.start_row() + self.normal_cell(date) + if self.use_srcs: + for s in addr.get_source_references(): + src_handle = s.get_reference_handle() + src = self.database.get_source_from_handle(src_handle) + text = "%s [%s]" % (text,src.get_gramps_id()) + self.slist.append(s) + self.normal_cell(text) + self.doc.end_row() + self.doc.end_table() + self.doc.start_paragraph('IDS-Normal') + self.doc.end_paragraph() + def write_families(self): if not len(self.start_person.get_family_handle_list()): @@ -507,6 +541,7 @@ class IndivCompleteReport(Report): self.write_facts() self.write_alt_parents() self.write_families() + self.write_addresses() self.write_note() self.write_sources() diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index 76bb61430..593db57bc 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -1727,8 +1727,7 @@ class IndividualPage(BasePage): of.write('\n') for addr in alist: - location = ", ".join([addr.get_street(),addr.get_city(), - addr.get_state(),addr.get_country()]) + location = ReportUtils.get_address_str(addr) location += self.get_citation_links( addr.get_source_references() ) date = _dd.display(addr.get_date_object())