Add manual url links on table rows

svn: r13730
This commit is contained in:
Doug Blank 2009-12-06 15:57:53 +00:00
parent 6e8f40e9f2
commit 9fd2e4a7fc
2 changed files with 21 additions and 8 deletions

View File

@ -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()

View File

@ -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: