From 51e4f545ed030f6a884d0d1b298f6bfdc3d6e0d9 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Fri, 15 Apr 2011 16:17:04 +0000 Subject: [PATCH] Added has_data interface to all quickviews svn: r17126 --- src/plugins/quickview/AgeOnDate.py | 1 + src/plugins/quickview/AttributeMatch.py | 1 + src/plugins/quickview/FilterByName.py | 1 + src/plugins/quickview/OnThisDay.py | 4 ++++ src/plugins/quickview/References.py | 2 ++ src/plugins/quickview/Reporef.py | 4 +++- src/plugins/quickview/SameSurnames.py | 2 ++ src/plugins/quickview/all_events.py | 6 +++++- src/plugins/quickview/siblings.py | 2 ++ 9 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugins/quickview/AgeOnDate.py b/src/plugins/quickview/AgeOnDate.py index 824994468..698cb9596 100644 --- a/src/plugins/quickview/AgeOnDate.py +++ b/src/plugins/quickview/AgeOnDate.py @@ -64,6 +64,7 @@ def run(database, document, date): stab.row_sort_val(1, int(diff_span)) matches += 1 + document.has_data = matches > 0 sdoc.paragraph(_("\n%d matches.\n") % matches) stab.write(sdoc) sdoc.paragraph("") diff --git a/src/plugins/quickview/AttributeMatch.py b/src/plugins/quickview/AttributeMatch.py index 4fbf77dc9..355155a72 100644 --- a/src/plugins/quickview/AttributeMatch.py +++ b/src/plugins/quickview/AttributeMatch.py @@ -42,5 +42,6 @@ def run(database, document, attribute, value=None): matched = True if matched: matches += 1 + document.has_data = matches > 0 sdoc.paragraph(_("There are %d people with a matching attribute name.\n") % matches) stab.write(sdoc) diff --git a/src/plugins/quickview/FilterByName.py b/src/plugins/quickview/FilterByName.py index 800da2340..17834870d 100644 --- a/src/plugins/quickview/FilterByName.py +++ b/src/plugins/quickview/FilterByName.py @@ -384,5 +384,6 @@ def run(database, document, filter_name, *args, **kwargs): , "Filter matched %d records.", matches) % matches) sdoc.paragraph("") + document.has_data = matches > 0 if matches > 0: stab.write(sdoc) diff --git a/src/plugins/quickview/OnThisDay.py b/src/plugins/quickview/OnThisDay.py index d381e14a7..f4bc13894 100644 --- a/src/plugins/quickview/OnThisDay.py +++ b/src/plugins/quickview/OnThisDay.py @@ -109,7 +109,9 @@ def run(database, document, main_event): sdb.event_type(event), sdb.event_place(event), ref) + document.has_data = False if stab.get_row_count() > 0: + document.has_data = True sdoc.paragraph(_("Events on this exact date")) stab.write(sdoc) else: @@ -118,6 +120,7 @@ def run(database, document, main_event): sdoc.paragraph("") if histab.get_row_count() > 0: + document.has_data = True sdoc.paragraph(_("Other events on this month/day in history")) histab.write(sdoc) else: @@ -126,6 +129,7 @@ def run(database, document, main_event): sdoc.paragraph("") if yeartab.get_row_count() > 0: + document.has_data = True sdoc.paragraph(_("Other events in %(year)d") % {"year":main_date.get_year()}) yeartab.write(sdoc) diff --git a/src/plugins/quickview/References.py b/src/plugins/quickview/References.py index 94292da9d..fbdf6d362 100644 --- a/src/plugins/quickview/References.py +++ b/src/plugins/quickview/References.py @@ -70,8 +70,10 @@ def run(database, document, object, item, trans): stab.row(_(objclass), ref) # translation are explicit (above) if stab.get_row_count() > 0: + document.has_data = True stab.write(sdoc) else: + document.has_data = False sdoc.paragraph(_("No references for this %s") % trans) sdoc.paragraph("") sdoc.paragraph("") diff --git a/src/plugins/quickview/Reporef.py b/src/plugins/quickview/Reporef.py index 05bdabc0e..ad25ed37f 100755 --- a/src/plugins/quickview/Reporef.py +++ b/src/plugins/quickview/Reporef.py @@ -56,6 +56,8 @@ def run(database, document, repo): database.find_backlink_handles(repo_handle, ['Source' ])] + stab.columns(_("Source"), _("Type of media"), _("Call number")) + document.has_data = False for source_handle in source_list: src = database.get_source_from_handle(source_handle) @@ -70,6 +72,6 @@ def run(database, document, repo): media = str(reporef.get_media_type()) call = reporef.get_call_number() - stab.columns(_("Source"), _("Type of media"), _("Call number")) stab.row(src.get_title(), media, call) + document.has_data = True stab.write(sdoc) diff --git a/src/plugins/quickview/SameSurnames.py b/src/plugins/quickview/SameSurnames.py index 3aacac8ff..95aaecd12 100644 --- a/src/plugins/quickview/SameSurnames.py +++ b/src/plugins/quickview/SameSurnames.py @@ -122,6 +122,7 @@ def run(database, document, person): str(person.get_primary_name().get_type())) matches += 1 + document.has_data = matches > 0 sdoc.paragraph(ngettext("There is %d person with a matching name, or alternate name.\n" , "There are %d people with a matching name, or alternate name.\n" @@ -163,6 +164,7 @@ def run_given(database, document, person): str(person.get_primary_name().get_type())) matches += 1 + document.has_data = matches > 0 sdoc.paragraph(ngettext("There is %d person with a matching name, or alternate name.\n" , "There are %d people with a matching name, or alternate name.\n" diff --git a/src/plugins/quickview/all_events.py b/src/plugins/quickview/all_events.py index 4af50e567..86d53a795 100644 --- a/src/plugins/quickview/all_events.py +++ b/src/plugins/quickview/all_events.py @@ -57,11 +57,12 @@ def run(database, document, person): sdoc.paragraph("") stab.columns(_("Event Type"), _("Event Date"), _("Event Place")) - + document.has_data = False for event in event_list: stab.row(event, sdb.event_date_obj(event), sdb.event_place(event)) + document.has_data = True stab.write(sdoc) def run_fam(database, document, family): @@ -99,6 +100,7 @@ def run_fam(database, document, family): 'father' : sdb.name(sdb.father(family)), 'mother' : sdb.name(sdb.mother(family)) }) sdoc.paragraph("") + document.has_data = False stab.columns(_("Family Member"), _("Event Type"), _("Event Date"), _("Event Place")) @@ -106,6 +108,7 @@ def run_fam(database, document, family): stab.row(person, sdb.event_type(event), sdb.event_date_obj(event), sdb.event_place(event)) + document.has_data = True stab.write(sdoc) stab = SimpleTable(sdb) @@ -116,6 +119,7 @@ def run_fam(database, document, family): stab.row(person, sdb.event_type(event), sdb.event_date_obj(event), sdb.event_place(event)) + document.has_data = True stab.write(sdoc) def fam_sort(event1, event2): diff --git a/src/plugins/quickview/siblings.py b/src/plugins/quickview/siblings.py index 5083fc7b8..08511712c 100644 --- a/src/plugins/quickview/siblings.py +++ b/src/plugins/quickview/siblings.py @@ -48,6 +48,7 @@ def run(database, document, person): # grab our current id (self): gid = sdb.gid(person) # loop through each family in which the person is a child + document.has_data = False for family in sdb.child_in(person): # loop through each child in the family for child in sdb.children(family): @@ -63,4 +64,5 @@ def run(database, document, person): sdb.gender(child), sdb.birth_or_fallback(child), rel_str) + document.has_data = True stab.write(sdoc)