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()
v_lat, v_lon = conv_lat_lon(data, "0.0",
coord_formats[self.report.options['coord_format']])
if not v_lat:
if data and not v_lat:
data += self._(":")
# We use the same message as in:
# gramps/gui/editors/editplace.py
@ -2993,7 +2993,7 @@ class BasePage:
data = place.get_longitude()
v_lat, v_lon = conv_lat_lon("0.0", data,
coord_formats[self.report.options['coord_format']])
if not v_lon:
if data and not v_lon:
data += self._(":")
# We use the same message as in:
# 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():
cname = sname = None
if len(handle_list[place_name]) == 4:
(hdle, pname, dummy_id, event) = handle_list[place_name]
else:
if len(handle_list[place_name]) == 6:
(hdle, pname, cname,
sname, dummy_id, event) = handle_list[place_name]
else:
continue
place = dbase.get_place_from_handle(hdle)
pname = _pd.display(dbase, place, fmt=0)
apname = _pd.display_event(dbase, event, fmt=0)

View File

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