8950 : Narrative web : html elements emitted in different order

This commit is contained in:
SNoiraud 2016-01-14 10:04:29 +01:00
parent f9930c1bcf
commit ee0e343e1e

View File

@ -647,7 +647,7 @@ class BasePage(object):
@param: place_lat_long -- for use in Family Map Pages. This will be None
if called from Family pages, which do not create a Family Map
"""
family_list = individual.get_family_handle_list()
family_list = sorted(individual.get_family_handle_list())
if not family_list:
return None
@ -1599,16 +1599,17 @@ class BasePage(object):
user_footer += note
msg = _('Generated by %(gramps_home_html_start)s'
'Gramps%(html_end)s %(version)s on %(date)s'
'Gramps%(html_end)s %(version)s'
) % {'gramps_home_html_start' :
'<a href="' + URL_HOMEPAGE + '">' ,
'html_end' : '</a>' ,
'version' : VERSION ,
'date' : _dd.display(Today()) }
'version' : VERSION }
if date is not None:
msg += "<br />"
last_modif = datetime.datetime.fromtimestamp(date).strftime('%Y-%m-%d %H:%M:%S')
msg += _('Last change was the %(date)s') % { 'date' : last_modif }
else:
msg += _(' on %(date)s') % { 'date' : _dd.display(Today()) }
# optional "link-home" feature; see bug report #2736
if self.report.options['linkhome']:
@ -2070,7 +2071,11 @@ class BasePage(object):
"""
# return media rectangles to its callers
return _region_items
# bug 8950 : it seems it's better to sort on name + coords of the rectangle.
def sort_by_name_and_rectangle(obj):
return(obj[0], obj[1], obj[2], obj[3], obj[4])
return sorted(_region_items, key=lambda x:sort_by_name_and_rectangle(x))
def media_ref_region_to_object(self, media_handle, obj):
"""
@ -2824,8 +2829,12 @@ class BasePage(object):
if depth > len(list_style):
return ""
# Sort by the name of the object at the bkref_class, bkref_handle
# bug 8950 : it seems it's better to sort on name + gid.
def sort_by_name_and_gid(obj):
return (obj[1], obj[2])
for (bkref_class, bkref_handle) in sorted(
bkref_list, key=lambda x:self.report.obj_dict[x[0]][x[1]][1]):
bkref_list, key=lambda x:sort_by_name_and_gid(self.report.obj_dict[x[0]][x[1]])):
list = Html("li")
path = self.report.obj_dict[bkref_class][bkref_handle][0]
name = self.report.obj_dict[bkref_class][bkref_handle][1]
@ -3163,10 +3172,10 @@ class FamilyPages(BasePage):
letter ='&nbsp;'
# get person from sorted database list
for person_handle in handle_list:
for person_handle in sorted(handle_list):
person = self.dbase_.get_person_from_handle(person_handle)
if person:
family_list = pers_fam_dict[person_handle]
family_list = sorted(pers_fam_dict[person_handle], key=lambda x:x.get_gramps_id())
first_family = True
for family in family_list:
trow = Html("tr")
@ -4837,9 +4846,12 @@ class ThumbnailPreviewPage(BasePage):
self.dbase_ = report.database
BasePage.__init__(self, report, title)
self.create_thumbs_only = report.options['create_thumbs_only']
# bug 8950 : it seems it's better to sort on desc + gid.
def sort_by_desc_and_gid(obj):
return (obj.desc, obj.gramps_id)
self.photo_keys = sorted(self.report.obj_dict[MediaObject],
key=lambda x: SORT_KEY(self.dbase_.get_object_from_handle(x).desc))
key=lambda x: sort_by_desc_and_gid(self.dbase_.get_object_from_handle(x)))
media_list = []
for person_handle in self.photo_keys:
@ -5233,7 +5245,7 @@ class PersonPages(BasePage):
len(self.report.obj_dict[Person]) + 1) as step:
self.IndividualListPage(self.report, title,
self.report.obj_dict[Person].keys())
for person_handle in self.report.obj_dict[Person]:
for person_handle in sorted(self.report.obj_dict[Person]):
step()
person = self.report.database.get_person_from_handle(person_handle)
self.IndividualPage(self.report, title, person)
@ -5314,7 +5326,7 @@ class PersonPages(BasePage):
surname = _ABSENT
first_surname = True
for person_handle in handle_list:
for person_handle in sorted(handle_list):
person = self.dbase_.get_person_from_handle(person_handle)
if person.get_change_time() > date: date = person.get_change_time()
@ -7736,7 +7748,7 @@ class NavWebReport(Report):
"surnames_count")
for (surname, handle_list) in local_list:
SurnamePage(self, self.title, surname, handle_list)
SurnamePage(self, self.title, surname, sorted(handle_list))
step()
def thumbnail_preview_page(self):