9016 : narrativeweb : refactor the previous patch using _pd.display_event()

This commit is contained in:
SNoiraud 2015-12-03 23:54:50 +01:00
parent 79395f14c6
commit d4c923bef3

View File

@ -2629,9 +2629,9 @@ class BasePage(object):
@param: place -- place object from the database @param: place -- place object from the database
@param: table -- table from Placedetail @param: table -- table from Placedetail
""" """
if place in self.visited: if place in self.report.visited:
return return
self.visited.append(place) self.report.visited.append(place)
# add table body # add table body
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
@ -3341,7 +3341,6 @@ class PlacePages(BasePage):
self.report = report self.report = report
self.db = report.database self.db = report.database
self.place_dict = defaultdict(set) self.place_dict = defaultdict(set)
self.visited = []
def display_pages(self, title): def display_pages(self, title):
""" """
@ -3413,22 +3412,18 @@ class PlacePages(BasePage):
) )
handle_list = sorted(place_handles, handle_list = sorted(place_handles,
key=lambda x: SORT_KEY(ReportUtils.place_name(self.dbase_, key=lambda x: SORT_KEY(ReportUtils.place_name(self.dbase_, x)))
x[:x.index(':')])))
first = True first = True
# begin table body # begin table body
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
for place_handle_key in handle_list: for place_handle in handle_list:
event_date = self.report.obj_dict[Place][place_handle_key][4]
place_handle = self.report.obj_dict[Place][place_handle_key][0]
place_name = self.report.obj_dict[Place][place_handle_key][2]
place = self.dbase_.get_place_from_handle(place_handle) place = self.dbase_.get_place_from_handle(place_handle)
if place: if place:
if place.get_change_time() > ldatec: ldatec = place.get_change_time() if place.get_change_time() > ldatec: ldatec = place.get_change_time()
place_title = _pd.display(self.dbase_, place, event_date) place_title = place.get_name().get_value()
ml = get_main_location(self.dbase_, place) ml = get_main_location(self.dbase_, place)
if place_title and not place_title.isspace(): if place_title and not place_title.isspace():
@ -3486,14 +3481,13 @@ class PlacePages(BasePage):
# and close the file # and close the file
self.XHTMLWriter(placelistpage, of, sio, ldatec) self.XHTMLWriter(placelistpage, of, sio, ldatec)
def PlacePage(self, report, title, key): def PlacePage(self, report, title, place_handle):
self.bibli = Bibliography() self.bibli = Bibliography()
self.dbase_ = report.database self.dbase_ = report.database
place_handle = self.report.obj_dict[Place][key][0] place_fname = self.report.obj_dict[Place][place_handle][0]
place_fname = self.report.obj_dict[Place][key][1] place_name = self.report.obj_dict[Place][place_handle][1]
place_name = self.report.obj_dict[Place][key][2] place_id = self.report.obj_dict[Place][place_handle][2]
place_id = self.report.obj_dict[Place][key][3] event = self.report.obj_dict[Place][place_handle][3]
event_date = self.report.obj_dict[Place][key][4]
place = self.dbase_.get_place_from_handle(place_handle) place = self.dbase_.get_place_from_handle(place_handle)
if not place: if not place:
return None return None
@ -3502,7 +3496,7 @@ class PlacePages(BasePage):
of, sio = self.report.create_file(place_handle, "plc") of, sio = self.report.create_file(place_handle, "plc")
self.up = True self.up = True
self.page_title = _pd.display(self.dbase_, place, event_date) self.page_title = _pd.display(self.dbase_, place)
placepage, head, body = self.write_header(_("Places")) placepage, head, body = self.write_header(_("Places"))
self.placemappages = self.report.options['placemappages'] self.placemappages = self.report.options['placemappages']
@ -7162,6 +7156,7 @@ class NavWebReport(Report):
################################################# #################################################
self.base_pages() self.base_pages()
self.visited = []
# build classes IndividualListPage and IndividualPage # build classes IndividualListPage and IndividualPage
self.tab["Person"].display_pages(self.title) self.tab["Person"].display_pages(self.title)
@ -7302,7 +7297,7 @@ class NavWebReport(Report):
self._add_event(evt_ref.ref, Person, person_handle) self._add_event(evt_ref.ref, Person, person_handle)
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
if place_handle: if place_handle:
self._add_place(place_handle, Person, person_handle, event.get_date_object()) self._add_place(place_handle, Person, person_handle, event)
# If event pages are not being output, then tell the # If event pages are not being output, then tell the
# media tab to display the perosn's event media. If # media tab to display the perosn's event media. If
# events are being displayed, then the media are linked # events are being displayed, then the media are linked
@ -7334,7 +7329,7 @@ class NavWebReport(Report):
self._add_event(evt_ref.ref, Person, person_handle) self._add_event(evt_ref.ref, Person, person_handle)
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
if place_handle: if place_handle:
self._add_place(place_handle, Person, person_handle, event.get_date_object()) self._add_place(place_handle, Person, person_handle, event)
for citation_handle in event.get_citation_list(): for citation_handle in event.get_citation_list():
self._add_citation( self._add_citation(
citation_handle, Person, person_handle) citation_handle, Person, person_handle)
@ -7418,7 +7413,7 @@ class NavWebReport(Report):
event = self.database.get_event_from_handle(evt_ref.ref) event = self.database.get_event_from_handle(evt_ref.ref)
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
if place_handle: if place_handle:
self._add_place(place_handle, Family, family_handle, event.get_date_object()) self._add_place(place_handle, Family, family_handle, event)
if self.inc_events: if self.inc_events:
# detail for family events are displayed on the events pages as # detail for family events are displayed on the events pages as
@ -7513,15 +7508,14 @@ class NavWebReport(Report):
media_handle = media_ref.get_reference_handle() media_handle = media_ref.get_reference_handle()
self._add_media(media_handle, Event, event_handle) self._add_media(media_handle, Event, event_handle)
def _add_place(self, place_handle, bkref_class, bkref_handle, date): def _add_place(self, place_handle, bkref_class, bkref_handle, event):
place = self.database.get_place_from_handle(place_handle) place = self.database.get_place_from_handle(place_handle)
if place is None: if place is None:
return return
place_name = _pd.display(self.database, place, date) place_name = _pd.display_event(self.database, event)
place_fname = self.build_url_fname(place_handle, "plc", place_fname = self.build_url_fname(place_handle, "plc",
False) + self.ext False) + self.ext
self.obj_dict[Place][place_handle+":"+place_name] = (place_handle, place_fname, place_name, self.obj_dict[Place][place_handle] = (place_fname, place_name, place.gramps_id, event)
place.gramps_id, date)
self.bkref_dict[Place][place_handle].add((bkref_class, bkref_handle)) self.bkref_dict[Place][place_handle].add((bkref_class, bkref_handle))
############### Media section ############## ############### Media section ##############
@ -8870,8 +8864,7 @@ def get_first_letters(dbase, handle_list, key):
keyname = __get_person_keyname(dbase, handle) keyname = __get_person_keyname(dbase, handle)
elif key == _KEYPLACE: elif key == _KEYPLACE:
real_handle = handle[:handle.index(':')] keyname = __get_place_keyname(dbase, handle)
keyname = __get_place_keyname(dbase, real_handle)
else: else:
keyname = handle keyname = handle