From 9fd2e4a7fc34fb57b44e2c45bc0538fd903326e7 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sun, 6 Dec 2009 15:57:53 +0000 Subject: [PATCH] Add manual url links on table rows svn: r13730 --- src/Simple/_SimpleTable.py | 16 ++++++++++++---- src/web/utils.py | 13 +++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Simple/_SimpleTable.py b/src/Simple/_SimpleTable.py index 64bb64d24..70a7e7c4e 100644 --- a/src/Simple/_SimpleTable.py +++ b/src/Simple/_SimpleTable.py @@ -183,6 +183,7 @@ class SimpleTable(object): def set_link_col(self, col): """ Manually sets the column that defines link. + col is either a number (column) or a (object_type_name, handle). """ self.__link_col = col @@ -313,12 +314,19 @@ class SimpleTable(object): doc.start_row() for col in row: doc.start_cell('TableDataCell', span=1) - if self.__link[index]: + obj_type, handle = None, None + if isinstance(self.__link_col, tuple): + obj_type, handle = self.__link_col + elif self.__link[index]: obj_type, handle = self.__link[index] - doc.start_link("/%s/%s" % - (obj_type.lower(), handle)) + if obj_type: + if obj_type.lower() == "url": + doc.start_link(handle) + else: + doc.start_link("/%s/%s" % + (obj_type.lower(), handle)) doc.write_text(col, 'Normal') - if self.__link[index]: + if obj_type: doc.stop_link() doc.end_cell() doc.end_row() diff --git a/src/web/utils.py b/src/web/utils.py index 5ab5f9217..b17b5d6fc 100644 --- a/src/web/utils.py +++ b/src/web/utils.py @@ -95,6 +95,9 @@ class Table(object): def row(self, *args): self.table.row(*args) + def link(self, object_type_name, handle): + self.table.set_link_col((object_type_name, handle)) + def get_html(self): self.table.write(self.doc) # forces to htmllist return str(self.doc.doc.htmllist[0]) @@ -147,6 +150,8 @@ def person_name_table(djperson, user): name.group_as, ["No", "Yes"][sourceq], note) + table.link('URL', "/person/%s/name/%s" % + (name.person.handle, name.id)) return table.get_html() def person_source_table(djperson, user): @@ -379,7 +384,7 @@ def display_date(obj): if date_tuple: gdate = GDate() gdate.unserialize(date_tuple) - return escape(_dd(gdate)) + return _dd(gdate) else: return "" @@ -410,12 +415,12 @@ def make_name(name, user): if not surname: surname = "[Missing]" if user.is_authenticated(): - return escape("%s, %s" % (surname, name.first_name)) + return "%s, %s" % (surname, name.first_name) else: if probably_alive(name.person.handle): - return escape("%s, %s" % (surname, "[Living]")) + return "%s, %s" % (surname, "[Living]") else: - return escape("%s, %s" % (surname, name.first_name)) + return "%s, %s" % (surname, name.first_name) elif name: # name_set name = name.get(preferred=True) if name: