Fix place format option in place report (#561)

* Fix place format option in place report

Resolves #10467.

* Use -1 instead of None for default place format

* adds New [Place format:] option on the [Report Options (2)] tab
This commit is contained in:
Nick Hall 2018-03-06 22:53:21 +00:00 committed by Sam Manzi
parent 433677c905
commit cf42e5a4b8
3 changed files with 10 additions and 8 deletions

View File

@ -75,7 +75,7 @@ class PlaceDisplay:
pf = PlaceFormat('Full', ':', '', 0, False) pf = PlaceFormat('Full', ':', '', 0, False)
self.place_formats.append(pf) self.place_formats.append(pf)
def display_event(self, db, event, fmt=None): def display_event(self, db, event, fmt=-1):
if not event: if not event:
return "" return ""
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
@ -85,13 +85,13 @@ class PlaceDisplay:
else: else:
return "" return ""
def display(self, db, place, date=None, fmt=None): def display(self, db, place, date=None, fmt=-1):
if not place: if not place:
return "" return ""
if not config.get('preferences.place-auto'): if not config.get('preferences.place-auto'):
return place.title return place.title
else: else:
if fmt is None: if fmt == -1:
fmt = config.get('preferences.place-format') fmt = config.get('preferences.place-format')
pf = self.place_formats[fmt] pf = self.place_formats[fmt]
lang = pf.language lang = pf.language

View File

@ -334,10 +334,9 @@ def add_place_format_option(menu, category):
Insert an option for changing the report's place format to a Insert an option for changing the report's place format to a
report-specific format instead of the user's Edit=>Preferences choice report-specific format instead of the user's Edit=>Preferences choice
""" """
place_format = EnumeratedListOption(_("Place format"), None) place_format = EnumeratedListOption(_("Place format"), -1)
place_format.add_item(None, _("Default")) place_format.add_item(-1, _("Default"))
for number, fmt in enumerate(_pd.get_formats()): for number, fmt in enumerate(_pd.get_formats()):
place_format.add_item(number, fmt.name) place_format.add_item(number, fmt.name)
place_format.set_help(_("Select the format to display places")) place_format.set_help(_("Select the format to display places"))
menu.add_option(category, "place_format", place_format) menu.add_option(category, "place_format", place_format)
return place_format

View File

@ -198,7 +198,7 @@ class PlaceReport(Report):
place_names += ' (%s)' % place_name.get_language() place_names += ' (%s)' % place_name.get_language()
place_details += [self._("places|All Names: %s") % place_names,] place_details += [self._("places|All Names: %s") % place_names,]
self.doc.start_paragraph("PLC-PlaceTitle") self.doc.start_paragraph("PLC-PlaceTitle")
place_title = _pd.display(self._db, place, self.place_format) place_title = _pd.display(self._db, place, None, self.place_format)
self.doc.write_text(("%(nbr)s. %(place)s") % {'nbr' : place_nbr, self.doc.write_text(("%(nbr)s. %(place)s") % {'nbr' : place_nbr,
'place' : place_title}) 'place' : place_title})
self.doc.end_paragraph() self.doc.end_paragraph()
@ -427,7 +427,8 @@ class PlaceOptions(MenuReportOptions):
if subject: if subject:
subject += " + " subject += " + "
place = self.__db.get_place_from_gramps_id(place_id) place = self.__db.get_place_from_gramps_id(place_id)
subject += _pd.display(self.__db, place, self.place_format) subject += _pd.display(self.__db, place, None,
self.place_format)
return subject return subject
def add_menu_options(self, menu): def add_menu_options(self, menu):
@ -461,6 +462,8 @@ class PlaceOptions(MenuReportOptions):
stdoptions.add_name_format_option(menu, category_name) stdoptions.add_name_format_option(menu, category_name)
stdoptions.add_place_format_option(menu, category_name)
stdoptions.add_private_data_option(menu, category_name) stdoptions.add_private_data_option(menu, category_name)
stdoptions.add_living_people_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name)