From 08aaa658eb832558c656957d023b8672c2f34e37 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sun, 6 Dec 2009 17:35:51 +0000 Subject: [PATCH] Empty table cells have clickable area, even if empty svn: r13732 --- src/data/Web_Mainz.css | 1 + src/data/templates/view_events.html | 6 +++--- src/data/templates/view_families.html | 4 ++-- src/data/templates/view_media.html | 2 +- src/data/templates/view_people.html | 4 ++-- src/data/templates/view_sources.html | 4 ++-- src/web/grampsdb/templatetags/my_tags.py | 17 ++++++++++++----- src/web/utils.py | 15 +++++++++++++-- 8 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/data/Web_Mainz.css b/src/data/Web_Mainz.css index 65cb2fb56..eee7225f8 100644 --- a/src/data/Web_Mainz.css +++ b/src/data/Web_Mainz.css @@ -345,6 +345,7 @@ table tr td.TableDataCell { } table tr td.TableDataCell a { + display: block; color: black; text-decoration: none; } diff --git a/src/data/templates/view_events.html b/src/data/templates/view_events.html index 1cf55e8af..fa8eb82a7 100644 --- a/src/data/templates/view_events.html +++ b/src/data/templates/view_events.html @@ -22,9 +22,9 @@ [{{event.gramps_id}}] {% if user.is_authenticated %} {{event.event_type|escape}} - {{event.description|escape}} - {{event|display_date}} - {{event.place.title|escape}} + {{event.description|nbsp}} + {{event|display_date|nbsp}} + {{event.place.title|nbsp}} {% else %} diff --git a/src/data/templates/view_families.html b/src/data/templates/view_families.html index 8f1d71d3e..c2769a241 100644 --- a/src/data/templates/view_families.html +++ b/src/data/templates/view_families.html @@ -18,8 +18,8 @@ {{ forloop.counter|row_count:page }} [{{family.gramps_id}}] - {{family.father.name_set|make_name:user}} - {{family.mother.name_set|make_name:user}} + {{family.father.name_set|make_name:user|nbsp}} + {{family.mother.name_set|make_name:user|nbsp}} {% if user.is_authenticated %} {{family.family_rel_type|escape}} {% else %} diff --git a/src/data/templates/view_media.html b/src/data/templates/view_media.html index ef059741c..a4bf3a2ca 100644 --- a/src/data/templates/view_media.html +++ b/src/data/templates/view_media.html @@ -21,7 +21,7 @@ [{{media.gramps_id}}] {% if user.is_authenticated %} {{media.mime|escape}} - {{media|display_date}} + {{media|display_date|nbsp}} {{media.path|escape}} {% else %} diff --git a/src/data/templates/view_people.html b/src/data/templates/view_people.html index fa844203a..531219058 100644 --- a/src/data/templates/view_people.html +++ b/src/data/templates/view_people.html @@ -27,8 +27,8 @@ [{{name.person.gramps_id|escape}}] {{name.person.gender_type|escape}} {% if user.is_authenticated %} - {{name.person|person_get_birth_date}} - {{name.person|person_get_death_date}} + {{name.person|person_get_birth_date|nbsp}} + {{name.person|person_get_death_date|nbsp}} {% else %} [Private] [Private] diff --git a/src/data/templates/view_sources.html b/src/data/templates/view_sources.html index 467d6b297..1fc820ff1 100644 --- a/src/data/templates/view_sources.html +++ b/src/data/templates/view_sources.html @@ -21,8 +21,8 @@ [{{source.gramps_id}}] {% if user.is_authenticated %} {{source.title|escape}} - {{source.pubinfo|escape}} - {{source.author|escape}} + {{source.pubinfo|nbsp}} + {{source.author|nbsp}} {% else %} diff --git a/src/web/grampsdb/templatetags/my_tags.py b/src/web/grampsdb/templatetags/my_tags.py index 34d141968..daa23a09f 100644 --- a/src/web/grampsdb/templatetags/my_tags.py +++ b/src/web/grampsdb/templatetags/my_tags.py @@ -1,14 +1,21 @@ from django.template import escape, Library +from django.utils.safestring import mark_safe from web.utils import * import web.utils register = Library() -util_filters = ['person_event_table', 'person_name_table', 'person_source_table', 'person_attribute_table', - 'person_address_table', 'person_note_table', 'person_gallery_table', 'person_internet_table', - 'person_association_table', 'person_lds_table', 'person_reference_table', - 'family_children_table', 'family_event_table', 'family_source_table', 'family_attribute_table', - 'family_note_table', 'family_gallery_table', 'family_lds_table'] +util_filters = ['person_event_table', 'person_name_table', + 'person_source_table', 'person_attribute_table', + 'person_address_table', 'person_note_table', + 'person_gallery_table', 'person_internet_table', + 'person_association_table', 'person_lds_table', + 'person_reference_table', + 'family_children_table', 'family_event_table', + 'family_source_table', 'family_attribute_table', + 'family_note_table', 'family_gallery_table', + 'family_lds_table', + 'nbsp'] for filter_name in util_filters: func = getattr(web.utils, filter_name) func.is_safe = True diff --git a/src/web/utils.py b/src/web/utils.py index b17b5d6fc..cd4aced85 100644 --- a/src/web/utils.py +++ b/src/web/utils.py @@ -37,6 +37,7 @@ from gen.lib.date import Date as GDate, Today from gen.plug import BasePluginManager from cli.grampscli import CLIManager from django.template import escape +from django.utils.safestring import mark_safe from django.contrib.contenttypes.models import ContentType #------------------------------------------------------------------------ @@ -68,6 +69,14 @@ def format_number(number, with_grouping=True): locale.setlocale(locale.LC_ALL, "en_US.utf8") return locale.format("%d", number, with_grouping) +def nbsp(string): + """ + """ + if string: + return escape(string) + else: + return mark_safe(" ") + class Table(object): """ >>> table = Table() @@ -93,14 +102,16 @@ class Table(object): self.table.columns(*args) def row(self, *args): - self.table.row(*args) + self.table.row(*[nbsp(arg) for arg in args]) def link(self, object_type_name, handle): self.table.set_link_col((object_type_name, handle)) def get_html(self): + # The HTML writer escapes data: self.table.write(self.doc) # forces to htmllist - return str(self.doc.doc.htmllist[0]) + # We have a couple of HTML bits that we want to unescape: + return str(self.doc.doc.htmllist[0]).replace(" ", " ") _ = lambda text: text