diff --git a/gramps/gen/filters/rules/place/_hasplace.py b/gramps/gen/filters/rules/place/_hasplace.py index 3bbce4a0e..f01161425 100644 --- a/gramps/gen/filters/rules/place/_hasplace.py +++ b/gramps/gen/filters/rules/place/_hasplace.py @@ -90,7 +90,16 @@ class HasPlace(Rule): Check each location for a match. """ for place_type, field in self.TYPE2FIELD.items(): - name = location.get(place_type, '') - if not self.match_substring(field, name): + name_list = location.get(place_type, ['']) + if not self.match_name(field, name_list): return False return True + + def match_name(self, field, name_list): + """ + Match any name in a list of names. + """ + for name in name_list: + if self.match_substring(field, name): + return True + return False diff --git a/gramps/gen/lib/place.py b/gramps/gen/lib/place.py index 36ea6d02f..1352b5d41 100644 --- a/gramps/gen/lib/place.py +++ b/gramps/gen/lib/place.py @@ -321,6 +321,15 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject): """ return self.name + def get_all_names(self): + """ + Return a list of all names of the Place object. + + :returns: Returns a list of all names of the Place + :rtype: list + """ + return [self.name] + self.alt_names + def set_longitude(self, longitude): """ Set the longitude of the Place object. diff --git a/gramps/gen/utils/location.py b/gramps/gen/utils/location.py index 003b8b0d0..de6721c11 100644 --- a/gramps/gen/utils/location.py +++ b/gramps/gen/utils/location.py @@ -64,14 +64,14 @@ def get_locations(db, place): containing dictionaries of place types and names. """ locations = [] - todo = [(place, [(int(place.get_type()), place.get_name())])] + todo = [(place, [(int(place.get_type()), place.get_all_names())])] while len(todo): place, tree = todo.pop() if len(place.get_placeref_list()): for parent in place.get_placeref_list(): parent_place = db.get_place_from_handle(parent.ref) parent_tree = tree + [(int(parent_place.get_type()), - parent_place.get_name())] + parent_place.get_all_names())] todo.append((parent_place, parent_tree)) else: locations.append(dict(tree))