Narweb: enclosed places not correctly sorted. (#977)

* Narweb: enclosed places nor correctly sorted.

Fixes #11487

* Narweb: some cleanup
This commit is contained in:
Serge Noiraud 2020-01-10 17:32:58 +01:00 committed by GitHub
parent 50d8b110ae
commit 8184f1b603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2755,7 +2755,25 @@ class BasePage: # pylint: disable=C1001
class_="ColumnAttribute", inline=True), class_="ColumnAttribute", inline=True),
) )
tbody += trow tbody += trow
for placeref in place.get_placeref_list():
def sort_by_enclosed_by(obj):
"""
Sort by enclosed by
"""
place_name = ""
parent_place = self.r_db.get_place_from_handle(obj.ref)
if parent_place:
place_name = parent_place.get_name().get_value()
return place_name
def sort_by_encl(obj):
"""
Sort by encloses
"""
return obj[0]
for placeref in sorted(place.get_placeref_list(),
key=sort_by_enclosed_by):
parent_place = self.r_db.get_place_from_handle(placeref.ref) parent_place = self.r_db.get_place_from_handle(placeref.ref)
if parent_place: if parent_place:
place_name = parent_place.get_name().get_value() place_name = parent_place.get_name().get_value()
@ -2777,6 +2795,7 @@ class BasePage: # pylint: disable=C1001
class_="ColumnAttribute", inline=True), class_="ColumnAttribute", inline=True),
) )
tbody += trow tbody += trow
encloses = []
for link in self.r_db.find_backlink_handles( for link in self.r_db.find_backlink_handles(
place.handle, include_classes=['Place']): place.handle, include_classes=['Place']):
child_place = self.r_db.get_place_from_handle(link[1]) child_place = self.r_db.get_place_from_handle(link[1])
@ -2784,15 +2803,20 @@ class BasePage: # pylint: disable=C1001
for placeref in child_place.get_placeref_list(): for placeref in child_place.get_placeref_list():
if placeref.ref == place.handle: if placeref.ref == place.handle:
place_name = child_place.get_name().get_value() place_name = child_place.get_name().get_value()
if child_place.handle in self.report.obj_dict[Place]: if link[1] in self.report.obj_dict[Place]:
place_hyper = self.place_link(child_place.handle, encloses.append((place_name, link[1]))
place_name,
uplink=self.uplink)
else: else:
place_hyper = place_name encloses.append((place_name, ""))
trow = Html("tr") + ( for (name, handle) in sorted(encloses, key=sort_by_encl):
Html("td", place_hyper, place_name = child_place.get_name().get_value()
class_="ColumnPlace", inline=True)) if handle and handle in self.report.obj_dict[Place]:
place_hyper = self.place_link(handle, name,
uplink=self.uplink)
else:
place_hyper = name
trow = Html("tr") + (
Html("td", place_hyper,
class_="ColumnPlace", inline=True))
tbody += trow tbody += trow
# return place table to its callers # return place table to its callers