diff --git a/ChangeLog b/ChangeLog index 18743befa..64d8604e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-11-18 Brian Matherly + * src/plugins/NarrativeWeb.py: Fix 0000543: Multimedia-Objects marked as + private are visible in narrative web-report + 2006-11-18 Alex Roitman * src/ReportBase/_StyleEditor.py (__init__): Translate string. diff --git a/src/ReportBase/_ReportUtils.py b/src/ReportBase/_ReportUtils.py index 889076cf9..25e54c394 100644 --- a/src/ReportBase/_ReportUtils.py +++ b/src/ReportBase/_ReportUtils.py @@ -1085,6 +1085,33 @@ def sanitize_list(obj_list,exclude_private): else: return obj_list +def sanitize_media_ref_list(db, media_ref_list, exclude_private): + """ + Removes private references and references to private objects + from the list. + + @param db: GRAMPS database to which the references belongs + @type db: GrampsDbBase + @param ref_list: references to objects that have a privacy flag + @type ref_list: list + @param exclude_private: indicates if objects marked private + are eliminated from the list + @type exclude_private: bool + @returns: references to objects that match the privacy request + @rtype: list + """ + if exclude_private == True: + new_list = [] + for media_ref in media_ref_list: + if media_ref.get_privacy() == False: + handle = media_ref.get_reference_handle() + media_object = db.get_object_from_handle(handle) + if media_object.get_privacy() == False: + new_list.append(media_ref) + return new_list + else: + return media_ref_list + def sanitize_person(db,person): """ Creates a new Person instance based off the passed Person @@ -1133,21 +1160,21 @@ def sanitize_person(db,person): # copy birth event event_ref = person.get_birth_ref() - if event_ref: + if event_ref and event_ref.get_privacy() == False: event = db.get_event_from_handle(event_ref.ref) if not event.get_privacy(): new_person.set_birth_ref(event_ref) # copy death event event_ref = person.get_death_ref() - if event_ref: + if event_ref and event_ref.get_privacy() == False: event = db.get_event_from_handle(event_ref.ref) if not event.get_privacy(): new_person.set_death_ref(event_ref) # copy event list for event_ref in person.get_event_ref_list(): - if event_ref: + if event_ref and event_ref.get_privacy() == False: event = db.get_event_from_handle(event_ref.ref) if not event.get_privacy(): new_person.add_event_ref(event_ref) @@ -1165,7 +1192,10 @@ def sanitize_person(db,person): # copy source references for ref in person.get_source_references(): if not ref.get_privacy(): - new_person.add_source_reference(RelLib.SourceRef(ref)) + handle = ref.get_reference_handle() + source = db.get_source_from_handle(handle) + if source.get_privacy() == False: + new_person.add_source_reference(RelLib.SourceRef(ref)) # copy URL list for url in person.get_url_list(): @@ -1173,9 +1203,9 @@ def sanitize_person(db,person): new_person.add_url(url) # copy Media reference list - for obj in person.get_media_list(): - if not obj.get_privacy(): - new_person.add_media_reference(RelLib.MediaRef(obj)) + clean_list = sanitize_media_ref_list(db,person.get_media_list(),True) + for ref in clean_list: + new_person.add_media_reference(RelLib.MediaRef(ref)) # LDS ordinances for lds_ord in person.get_lds_ord_list(): diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index ce677fe0b..4174f80a2 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -739,7 +739,7 @@ class PlacePage(BasePage): get_researcher().get_name(),up=True) media_list = place.get_media_list() - media_list = ReportUtils.sanitize_list( media_list, self.exclude_private) + media_list = ReportUtils.sanitize_media_ref_list( db, media_list, self.exclude_private) self.display_first_image_as_thumbnail(of, db, media_list) of.write('
\n') @@ -1165,7 +1165,7 @@ class SourcePage(BasePage): get_researcher().get_name(),up=True) media_list = source.get_media_list() - media_list = ReportUtils.sanitize_list( media_list, self.exclude_private) + media_list = ReportUtils.sanitize_media_ref_list(db, media_list, self.exclude_private) self.display_first_image_as_thumbnail(of, db, media_list) of.write('
\n') @@ -1368,26 +1368,27 @@ class IndividualPage(BasePage): if not self.restrict: media_list = [] - photolist = ReportUtils.sanitize_list(self.person.get_media_list(), - self.exclude_private) + photolist = ReportUtils.sanitize_media_ref_list( db, + self.person.get_media_list(), + self.exclude_private ) if len(photolist) > 1: media_list = photolist[1:] for handle in self.person.get_family_handle_list(): family = self.db.get_family_from_handle(handle) - media_list += ReportUtils.sanitize_list(family.get_media_list(), - self.exclude_private) + media_list += ReportUtils.sanitize_media_ref_list( db, + family.get_media_list(), + self.exclude_private ) for evt_ref in family.get_event_ref_list(): event = self.db.get_event_from_handle(evt_ref.ref) - media_list += ReportUtils.sanitize_list( - event.get_media_list(), - self.exclude_private) - + media_list += ReportUtils.sanitize_media_ref_list( db, + event.get_media_list(), + self.exclude_private ) for evt_ref in self.person.get_event_ref_list(): event = self.db.get_event_from_handle(evt_ref.ref) if event: - media_list += ReportUtils.sanitize_list( - event.get_media_list(), - self.exclude_private ) + media_list += ReportUtils.sanitize_media_ref_list( db, + event.get_media_list(), + self.exclude_private ) self.display_additional_images_as_gallery(of, db, media_list)