Fix some problems after commit 35f20a88

- Some places are not created so we have a 404 error
- If we have no latitude, longitude, don't show an error format

Fixes #12821
This commit is contained in:
SNoiraud 2023-06-09 09:49:10 +02:00 committed by Nick Hall
parent b70087fd78
commit 87b192b8d2
3 changed files with 25 additions and 14 deletions

View File

@ -2974,7 +2974,7 @@ class BasePage:
data = place.get_latitude() data = place.get_latitude()
v_lat, v_lon = conv_lat_lon(data, "0.0", v_lat, v_lon = conv_lat_lon(data, "0.0",
coord_formats[self.report.options['coord_format']]) coord_formats[self.report.options['coord_format']])
if not v_lat: if data and not v_lat:
data += self._(":") data += self._(":")
# We use the same message as in: # We use the same message as in:
# gramps/gui/editors/editplace.py # gramps/gui/editors/editplace.py
@ -2993,7 +2993,7 @@ class BasePage:
data = place.get_longitude() data = place.get_longitude()
v_lat, v_lon = conv_lat_lon("0.0", data, v_lat, v_lon = conv_lat_lon("0.0", data,
coord_formats[self.report.options['coord_format']]) coord_formats[self.report.options['coord_format']])
if not v_lon: if data and not v_lon:
data += self._(":") data += self._(":")
# We use the same message as in: # We use the same message as in:
# gramps/gui/editors/editplace.py # gramps/gui/editors/editplace.py

View File

@ -514,11 +514,11 @@ def sort_places(dbase, handle_list, rlocale=glocale):
for place_name in handle_list.keys(): for place_name in handle_list.keys():
cname = sname = None cname = sname = None
if len(handle_list[place_name]) == 4: if len(handle_list[place_name]) == 6:
(hdle, pname, dummy_id, event) = handle_list[place_name]
else:
(hdle, pname, cname, (hdle, pname, cname,
sname, dummy_id, event) = handle_list[place_name] sname, dummy_id, event) = handle_list[place_name]
else:
continue
place = dbase.get_place_from_handle(hdle) place = dbase.get_place_from_handle(hdle)
pname = _pd.display(dbase, place, fmt=0) pname = _pd.display(dbase, place, fmt=0)
apname = _pd.display_event(dbase, event, fmt=0) apname = _pd.display_event(dbase, event, fmt=0)

View File

@ -145,7 +145,13 @@ class PlacePages(BasePage):
place.gramps_id, None) place.gramps_id, None)
self.report.obj_dict[Place][place_ref] = plc_dict self.report.obj_dict[Place][place_ref] = plc_dict
p_name = _pd.display(self.r_db, place, fmt=0) p_name = _pd.display(self.r_db, place, fmt=0)
cplace_name = p_name.split()[-1]
if len(place_name.split()) > 1:
splace_name = place_name.split()[-2]
else:
splace_name = cplace_name
plc_dict = (place_ref, p_name, plc_dict = (place_ref, p_name,
splace_name, cplace_name,
place.gramps_id, None) place.gramps_id, None)
self.report.obj_dict[PlaceName][p_name] = plc_dict self.report.obj_dict[PlaceName][p_name] = plc_dict
@ -157,8 +163,9 @@ class PlacePages(BasePage):
step() step()
p_handle = self.report.obj_dict[PlaceName][place_name] p_handle = self.report.obj_dict[PlaceName][place_name]
index += 1 index += 1
self.placepage(self.report, the_lang, the_title, p_handle[0], if isinstance(p_handle, tuple):
place_name) self.placepage(self.report, the_lang, the_title, p_handle[0],
place_name)
step() step()
self.placelistpage(self.report, the_lang, the_title) self.placelistpage(self.report, the_lang, the_title)
@ -341,9 +348,13 @@ class PlacePages(BasePage):
continue continue
val = self.report.obj_dict[PlaceName][pname] val = self.report.obj_dict[PlaceName][pname]
nbelem = len(val) nbelem = len(val)
if nbelem > 3: if val and nbelem > 3:
place = self.r_db.get_place_from_handle( if isinstance(place_handle, tuple):
place_handle) place = self.r_db.get_place_from_handle(
place_handle[0])
else:
place = self.r_db.get_place_from_handle(
place_handle)
main_location = get_main_location(self.r_db, main_location = get_main_location(self.r_db,
place) place)
sname = main_location.get(PlaceType.STATE, '') sname = main_location.get(PlaceType.STATE, '')
@ -391,8 +402,8 @@ class PlacePages(BasePage):
ldatec = place.get_change_time() ldatec = place.get_change_time()
apname = _pd.display(self.r_db, place, fmt=0) apname = _pd.display(self.r_db, place, fmt=0)
if place_name == apname: # store only the primary named page # if place_name: # != apname: # store only the primary named page
output_file, sio = self.report.create_file(place_handle, "plc") output_file, sio = self.report.create_file(place_handle, "plc")
self.uplink = True self.uplink = True
self.page_title = place_name self.page_title = place_name
(placepage, head, dummy_body, (placepage, head, dummy_body,
@ -619,6 +630,6 @@ class PlacePages(BasePage):
# send page out for processing # send page out for processing
# and close the file # and close the file
if place_name == apname: # store only the primary named page # if place_name: # != apname: # store only the primary named page
self.xhtml_writer(placepage, output_file, sio, ldatec) self.xhtml_writer(placepage, output_file, sio, ldatec)