* src/RelLib.py (SourceNote): Add methods for detection and removal
source references in itself and child objects; (SourceNote,Person, Family,Event,Place,Source,MediaRef): Add method for determining child sourceref-capable objects. * src/Utils.py (get_source_referents): Add function. * src/EditSource.py (display_references): Use new sourceref detection; (DelSrcQuery.__init__): Accept object lists; (DelSrcQuery.query_response): Use new sourceref removal. * src/SourceView.py (on_delete_clicked): Use new sourceref detection; (delete_source,is_used): Remove functions. svn: r4160
This commit is contained in:
51
src/Utils.py
51
src/Utils.py
@ -109,7 +109,9 @@ def family_name(family,db):
|
||||
if father and mother:
|
||||
fname = NameDisplay.displayer.display(father)
|
||||
mname = NameDisplay.displayer.display(mother)
|
||||
name = _("%s and %s") % (fname,mname)
|
||||
name = _("%(father)s and %(mother)s") % {
|
||||
"father" : fname,
|
||||
"mother" : mname}
|
||||
elif father:
|
||||
name = NameDisplay.displayer.display(father)
|
||||
else:
|
||||
@ -491,6 +493,53 @@ def not_too_old(date):
|
||||
year = date.get_year()
|
||||
return not( year != 0 and current_year - year > 110)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def get_source_referents(source_handle,db):
|
||||
"""
|
||||
Find objects that refer the source.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
"""
|
||||
|
||||
# Persons
|
||||
person_list = [ handle \
|
||||
for handle in db.get_person_handles(sort_handles=False) \
|
||||
if db.get_person_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
|
||||
# Families
|
||||
family_list = [ handle for handle in db.get_family_handles() \
|
||||
if db.get_family_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
|
||||
# Events
|
||||
event_list = [ handle for handle in db.get_event_handles() \
|
||||
if db.get_event_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
|
||||
# Places
|
||||
place_list = [ handle for handle in db.get_place_handles() \
|
||||
if db.get_place_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
|
||||
# Sources
|
||||
source_list = [ handle for handle in db.get_source_handles() \
|
||||
if db.get_source_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
|
||||
# Media Objects
|
||||
media_list = [ handle for handle in db.get_media_object_handles() \
|
||||
if db.get_object_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
|
||||
return (person_list,family_list,event_list,
|
||||
place_list,source_list,media_list)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
|
Reference in New Issue
Block a user