* src/plugins/NarrativeWeb.py: Fix 0000543: Multimedia-Objects marked as private are visible in narrative web-report

svn: r7648
This commit is contained in:
Brian Matherly 2006-11-19 04:40:24 +00:00
parent 115892cc8d
commit 9b9d0fc574
3 changed files with 55 additions and 20 deletions

View File

@ -1,3 +1,7 @@
2006-11-18 Brian Matherly <brian@gramps-project.org>
* src/plugins/NarrativeWeb.py: Fix 0000543: Multimedia-Objects marked as
private are visible in narrative web-report
2006-11-18 Alex Roitman <shura@gramps-project.org>
* src/ReportBase/_StyleEditor.py (__init__): Translate string.

View File

@ -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():

View File

@ -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('<div id="summaryarea">\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('<div id="summaryarea">\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)