Narrative web: Solves some problems
Force place name to be "Full" names. Force the country field to be the last field of the place name Force the State/province to be the penultimate field of the place name We use place names that stop in the country, but iff we have place names such as: city, province, country, continent, planet with the continent and planet as the custom place type, the State/Province field will be the name of the place continent... (should never happen, but...) Fixes #12821
This commit is contained in:
parent
09fd85ef09
commit
35f20a8893
@ -881,7 +881,7 @@ class BasePage:
|
|||||||
found = any(data[3] == place_handle and data[4] == event_date
|
found = any(data[3] == place_handle and data[4] == event_date
|
||||||
for data in place_lat_long)
|
for data in place_lat_long)
|
||||||
if not found:
|
if not found:
|
||||||
placetitle = _pd.display(self.r_db, place)
|
placetitle = _pd.display(self.r_db, place, fmt=0)
|
||||||
latitude = place.get_latitude()
|
latitude = place.get_latitude()
|
||||||
longitude = place.get_longitude()
|
longitude = place.get_longitude()
|
||||||
if latitude and longitude:
|
if latitude and longitude:
|
||||||
@ -1012,7 +1012,8 @@ class BasePage:
|
|||||||
|
|
||||||
place_hyper = None
|
place_hyper = None
|
||||||
if place:
|
if place:
|
||||||
place_name = _pd.display(self.r_db, place, evt.get_date_object())
|
place_name = _pd.display(self.r_db, place,
|
||||||
|
evt.get_date_object(), fmt=0)
|
||||||
place_hyper = self.place_link(place_handle, place_name,
|
place_hyper = self.place_link(place_handle, place_name,
|
||||||
uplink=uplink)
|
uplink=uplink)
|
||||||
|
|
||||||
@ -1076,7 +1077,7 @@ class BasePage:
|
|||||||
if place_handle:
|
if place_handle:
|
||||||
place = self.r_db.get_place_from_handle(place_handle)
|
place = self.r_db.get_place_from_handle(place_handle)
|
||||||
if place:
|
if place:
|
||||||
place_title = _pd.display(self.r_db, place)
|
place_title = _pd.display(self.r_db, place, fmt=0)
|
||||||
place_hyper = self.place_link(
|
place_hyper = self.place_link(
|
||||||
place_handle, place_title,
|
place_handle, place_title,
|
||||||
place.get_gramps_id(), uplink=True)
|
place.get_gramps_id(), uplink=True)
|
||||||
@ -2165,7 +2166,7 @@ class BasePage:
|
|||||||
"evt", True)
|
"evt", True)
|
||||||
elif classname == "Place":
|
elif classname == "Place":
|
||||||
_obj = self.r_db.get_place_from_handle(newhandle)
|
_obj = self.r_db.get_place_from_handle(newhandle)
|
||||||
_name = _pd.display(self.r_db, _obj)
|
_name = _pd.display(self.r_db, _obj, fmt=0)
|
||||||
if not _name:
|
if not _name:
|
||||||
_name = self._("Unknown")
|
_name = self._("Unknown")
|
||||||
_linkurl = self.report.build_url_fname_html(newhandle,
|
_linkurl = self.report.build_url_fname_html(newhandle,
|
||||||
|
@ -513,14 +513,18 @@ def sort_places(dbase, handle_list, rlocale=glocale):
|
|||||||
pname_sub = defaultdict(list)
|
pname_sub = defaultdict(list)
|
||||||
|
|
||||||
for place_name in handle_list.keys():
|
for place_name in handle_list.keys():
|
||||||
(hdle, pname, dummy_id, event) = handle_list[place_name]
|
cname = sname = None
|
||||||
|
if len(handle_list[place_name]) == 4:
|
||||||
|
(hdle, pname, dummy_id, event) = handle_list[place_name]
|
||||||
|
else:
|
||||||
|
(hdle, pname, cname,
|
||||||
|
sname, dummy_id, event) = handle_list[place_name]
|
||||||
place = dbase.get_place_from_handle(hdle)
|
place = dbase.get_place_from_handle(hdle)
|
||||||
pname = _pd.display(dbase, place)
|
pname = _pd.display(dbase, place, fmt=0)
|
||||||
apname = _pd.display_event(dbase, event)
|
apname = _pd.display_event(dbase, event, fmt=0)
|
||||||
|
|
||||||
pname_sub[pname].append(hdle)
|
pname_sub[pname].append(hdle)
|
||||||
if pname != apname:
|
pname_sub[apname].append((hdle, pname, cname, sname))
|
||||||
pname_sub[apname].append(hdle)
|
|
||||||
|
|
||||||
sorted_lists = []
|
sorted_lists = []
|
||||||
temp_list = sorted(pname_sub, key=rlocale.sort_key)
|
temp_list = sorted(pname_sub, key=rlocale.sort_key)
|
||||||
|
@ -441,6 +441,7 @@ class FamilyPages(BasePage):
|
|||||||
relationshipdetail += families
|
relationshipdetail += families
|
||||||
|
|
||||||
# display additional images as gallery
|
# display additional images as gallery
|
||||||
|
if self.create_media:
|
||||||
addgallery = self.disp_add_img_as_gallery(media_list, family)
|
addgallery = self.disp_add_img_as_gallery(media_list, family)
|
||||||
if addgallery:
|
if addgallery:
|
||||||
relationshipdetail += addgallery
|
relationshipdetail += addgallery
|
||||||
|
@ -939,11 +939,20 @@ class NavWebReport(Report):
|
|||||||
else:
|
else:
|
||||||
name = ""
|
name = ""
|
||||||
if config.get('preferences.place-auto'):
|
if config.get('preferences.place-auto'):
|
||||||
place_name = _pd.display_event(self._db, event)
|
place_name = _pd.display_event(self._db, event, fmt=0)
|
||||||
pplace_name = _pd.display(self._db, place)
|
if event:
|
||||||
|
cplace_name = place_name.split()[-1]
|
||||||
|
if len(place_name.split()) > 1:
|
||||||
|
splace_name = place_name.split()[-2]
|
||||||
|
else:
|
||||||
|
splace_name = cplace_name
|
||||||
|
else:
|
||||||
|
cplace_name = None
|
||||||
|
splace_name = None
|
||||||
else:
|
else:
|
||||||
place_name = place.get_title()
|
place_name = place.get_title()
|
||||||
pplace_name = place_name
|
cplace_name = place_name
|
||||||
|
splace_name = place_name
|
||||||
if event:
|
if event:
|
||||||
if self.reference_sort:
|
if self.reference_sort:
|
||||||
role_or_date = name
|
role_or_date = name
|
||||||
@ -961,10 +970,8 @@ class NavWebReport(Report):
|
|||||||
self.obj_dict[Place][place_handle] = (place_fname, place_name,
|
self.obj_dict[Place][place_handle] = (place_fname, place_name,
|
||||||
place.gramps_id, event)
|
place.gramps_id, event)
|
||||||
self.obj_dict[PlaceName][place_name] = (place_handle, place_name,
|
self.obj_dict[PlaceName][place_name] = (place_handle, place_name,
|
||||||
|
splace_name, cplace_name,
|
||||||
place.gramps_id, event)
|
place.gramps_id, event)
|
||||||
if place_name != pplace_name:
|
|
||||||
self.obj_dict[PlaceName][pplace_name] = (place_handle, pplace_name,
|
|
||||||
place.gramps_id, event)
|
|
||||||
self.bkref_dict[Place][place_handle].add((bkref_class, bkref_handle,
|
self.bkref_dict[Place][place_handle].add((bkref_class, bkref_handle,
|
||||||
role_or_date
|
role_or_date
|
||||||
))
|
))
|
||||||
|
@ -1703,14 +1703,14 @@ class PersonPages(BasePage):
|
|||||||
birth = self.r_db.get_event_from_handle(birth_ref.ref)
|
birth = self.r_db.get_event_from_handle(birth_ref.ref)
|
||||||
if birth:
|
if birth:
|
||||||
birth_date = birth.get_date_object()
|
birth_date = birth.get_date_object()
|
||||||
p_birth = _pd.display_event(self.r_db, birth)
|
p_birth = _pd.display_event(self.r_db, birth, fmt=0)
|
||||||
|
|
||||||
death_ref = self.person.get_death_ref()
|
death_ref = self.person.get_death_ref()
|
||||||
p_death = ""
|
p_death = ""
|
||||||
if death_ref:
|
if death_ref:
|
||||||
death = self.r_db.get_event_from_handle(death_ref.ref)
|
death = self.r_db.get_event_from_handle(death_ref.ref)
|
||||||
if death:
|
if death:
|
||||||
p_death = _pd.display_event(self.r_db, death)
|
p_death = _pd.display_event(self.r_db, death, fmt=0)
|
||||||
|
|
||||||
death_date = _find_death_date(self.r_db, self.person)
|
death_date = _find_death_date(self.r_db, self.person)
|
||||||
if birth_date and birth_date is not Date.EMPTY:
|
if birth_date and birth_date is not Date.EMPTY:
|
||||||
|
@ -144,7 +144,7 @@ class PlacePages(BasePage):
|
|||||||
plc_dict = (p_fname, place_name,
|
plc_dict = (p_fname, place_name,
|
||||||
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)
|
p_name = _pd.display(self.r_db, place, fmt=0)
|
||||||
plc_dict = (place_ref, p_name,
|
plc_dict = (place_ref, p_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
|
||||||
@ -163,13 +163,22 @@ class PlacePages(BasePage):
|
|||||||
self.placelistpage(self.report, the_lang, the_title)
|
self.placelistpage(self.report, the_lang, the_title)
|
||||||
|
|
||||||
|
|
||||||
def __output_place(self, ldatec, tbody,
|
def __output_place(self, ldatec, tbody, first_place,
|
||||||
first_place, pname, place_handle, letter, bucket_link):
|
pname, sname, cname, place_handle, letter, bucket_link):
|
||||||
place = self.r_db.get_place_from_handle(place_handle)
|
place = self.r_db.get_place_from_handle(place_handle)
|
||||||
if place:
|
if place:
|
||||||
if place.get_change_time() > ldatec:
|
if place.get_change_time() > ldatec:
|
||||||
ldatec = place.get_change_time()
|
ldatec = place.get_change_time()
|
||||||
|
nbrs = len(pname.split(','))
|
||||||
plc_title = pname
|
plc_title = pname
|
||||||
|
if nbrs == 3:
|
||||||
|
plc_title = ", ".join(pname.split(',')[:1])
|
||||||
|
elif nbrs == 4:
|
||||||
|
plc_title = ", ".join(pname.split(',')[:2])
|
||||||
|
elif nbrs == 5:
|
||||||
|
plc_title = ", ".join(pname.split(',')[:3])
|
||||||
|
elif nbrs == 6:
|
||||||
|
plc_title = ", ".join(pname.split(',')[:4])
|
||||||
main_location = get_main_location(self.r_db, place)
|
main_location = get_main_location(self.r_db, place)
|
||||||
if not plc_title or plc_title == " ":
|
if not plc_title or plc_title == " ":
|
||||||
letter = " "
|
letter = " "
|
||||||
@ -195,10 +204,13 @@ class PlacePages(BasePage):
|
|||||||
trow.extend(Html("td", data or " ", class_=colclass,
|
trow.extend(Html("td", data or " ", class_=colclass,
|
||||||
inline=True) for
|
inline=True) for
|
||||||
(colclass, data) in [
|
(colclass, data) in [
|
||||||
["ColumnState",
|
# Use the two last field of a place
|
||||||
main_location.get(PlaceType.STATE, '')],
|
# We could have strange values if we
|
||||||
["ColumnCountry",
|
# have a placename like:
|
||||||
main_location.get(PlaceType.COUNTRY, '')]])
|
# city, province, country, mainland, planet...
|
||||||
|
# mainland and planet are custom types
|
||||||
|
["ColumnState", sname],
|
||||||
|
["ColumnCountry", cname]])
|
||||||
if self.display_coordinates:
|
if self.display_coordinates:
|
||||||
tcell1 = Html("td", class_="ColumnLatitude", inline=True)
|
tcell1 = Html("td", class_="ColumnLatitude", inline=True)
|
||||||
tcell2 = Html("td", class_="ColumnLongitude", inline=True)
|
tcell2 = Html("td", class_="ColumnLongitude", inline=True)
|
||||||
@ -323,10 +335,25 @@ class PlacePages(BasePage):
|
|||||||
self.rlocale)
|
self.rlocale)
|
||||||
first_place = True
|
first_place = True
|
||||||
for (pname, place_handle) in handle_list:
|
for (pname, place_handle) in handle_list:
|
||||||
|
if not pname:
|
||||||
|
continue
|
||||||
|
val = self.report.obj_dict[PlaceName][pname]
|
||||||
|
nbelem = len(val)
|
||||||
|
if nbelem == 4:
|
||||||
|
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, '')
|
||||||
|
cname = main_location.get(PlaceType.COUNTRY, '')
|
||||||
|
else:
|
||||||
|
cname = val[3]
|
||||||
|
sname = val[2]
|
||||||
(ldatec, first_place) \
|
(ldatec, first_place) \
|
||||||
= self.__output_place(ldatec,
|
= self.__output_place(ldatec,
|
||||||
trow, first_place, pname,
|
trow, first_place,
|
||||||
place_handle, bucket_letter,
|
pname, sname, cname,
|
||||||
|
val[0], bucket_letter,
|
||||||
bucket_link)
|
bucket_link)
|
||||||
|
|
||||||
# add clearline for proper styling
|
# add clearline for proper styling
|
||||||
@ -356,7 +383,7 @@ class PlacePages(BasePage):
|
|||||||
place.get_gramps_id())
|
place.get_gramps_id())
|
||||||
self.bibli = Bibliography()
|
self.bibli = Bibliography()
|
||||||
ldatec = place.get_change_time()
|
ldatec = place.get_change_time()
|
||||||
apname = _pd.display(self.r_db, place)
|
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")
|
||||||
|
Loading…
Reference in New Issue
Block a user