2008-01-18 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/plugins/DefaultGramplets.py (SurnameCloudGramplet.main): use const.NO_SURNAME to display blank entries * src/plugins/SameSurnames.py (SameSurname): exact match surnames * src/Simple/_SimpleAccess.py (SimpleAccess.surname): surname() returns const.NO_SURNAME when left blank * src/const.py.in: new NO_SURNAME constant; RERUN ./autogen.sh ! svn: r9887
This commit is contained in:
@@ -31,6 +31,7 @@ from BasicUtils import name_displayer
|
||||
from QuickReports import run_quick_report_by_name
|
||||
import DateHandler
|
||||
from gettext import gettext as _
|
||||
import const
|
||||
|
||||
#
|
||||
# Hello World, in Gramps Gramplets
|
||||
@@ -243,7 +244,7 @@ class TopSurnamesGramplet(Gramplet):
|
||||
self.set_text("")
|
||||
for (count, surname) in surname_sort:
|
||||
if len(surname) == 0:
|
||||
text = "(%s), %d%% (%d)\n" % (_("blank"), # as in empty, left blank
|
||||
text = "%s, %d%% (%d)\n" % (const.NO_SURNAME,
|
||||
int((float(count)/total) * 100), count)
|
||||
else:
|
||||
text = "%s, %d%% (%d)\n" % (surname, int((float(count)/total) * 100), count)
|
||||
@@ -329,11 +330,9 @@ class SurnameCloudGramplet(Gramplet):
|
||||
self.set_text("")
|
||||
for (count, surname) in cloud_names: # surname_sort:
|
||||
if len(surname) == 0:
|
||||
text = "(%s)" % _("blank")
|
||||
# int((float(count)/total) * 100), count)
|
||||
text = const.NO_SURNAME
|
||||
else:
|
||||
text = surname
|
||||
#
|
||||
size = make_tag_size(count, counts)
|
||||
self.link(text, 'Surname', representative_handle[surname], size,
|
||||
"%s, %d%% (%d)" % (text,
|
||||
|
||||
@@ -28,7 +28,6 @@ from gettext import gettext as _
|
||||
from PluginUtils import register_quick_report
|
||||
from ReportBase import CATEGORY_QR_PERSON
|
||||
from Filters.Rules import Rule
|
||||
from Filters.Rules.Person import SearchName
|
||||
from Filters import GenericFilterFactory, Rules
|
||||
|
||||
class IncompleteSurname(Rule):
|
||||
@@ -42,6 +41,19 @@ class IncompleteSurname(Rule):
|
||||
return True
|
||||
return False
|
||||
|
||||
class SameSurname(Rule):
|
||||
"""People with same surname"""
|
||||
labels = [_('Substring:')]
|
||||
name = _('People matching the <name>')
|
||||
description = _("Matches people with same lastname")
|
||||
category = _('General filters')
|
||||
def apply(self,db,person):
|
||||
src = self.list[0].upper()
|
||||
for name in [person.get_primary_name()] + person.get_alternate_names():
|
||||
if name.surname and name.surname.upper() == src.upper():
|
||||
return True
|
||||
return False
|
||||
|
||||
def run(database, document, person):
|
||||
"""
|
||||
Loops through the families that the person is a child in, and display
|
||||
@@ -59,7 +71,7 @@ def run(database, document, person):
|
||||
gid = sdb.gid(person)
|
||||
filter = GenericFilterFactory('Person')()
|
||||
if person.get_primary_name().get_surname() != '':
|
||||
rule = SearchName([person.get_primary_name().get_surname()])
|
||||
rule = SameSurname([person.get_primary_name().get_surname()])
|
||||
else:
|
||||
rule = IncompleteSurname([])
|
||||
filter.add_rule(rule)
|
||||
|
||||
Reference in New Issue
Block a user