Add manual url links on table rows
svn: r13730
This commit is contained in:
parent
6e8f40e9f2
commit
9fd2e4a7fc
@ -183,6 +183,7 @@ class SimpleTable(object):
|
|||||||
def set_link_col(self, col):
|
def set_link_col(self, col):
|
||||||
"""
|
"""
|
||||||
Manually sets the column that defines link.
|
Manually sets the column that defines link.
|
||||||
|
col is either a number (column) or a (object_type_name, handle).
|
||||||
"""
|
"""
|
||||||
self.__link_col = col
|
self.__link_col = col
|
||||||
|
|
||||||
@ -313,12 +314,19 @@ class SimpleTable(object):
|
|||||||
doc.start_row()
|
doc.start_row()
|
||||||
for col in row:
|
for col in row:
|
||||||
doc.start_cell('TableDataCell', span=1)
|
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]
|
obj_type, handle = self.__link[index]
|
||||||
doc.start_link("/%s/%s" %
|
if obj_type:
|
||||||
(obj_type.lower(), handle))
|
if obj_type.lower() == "url":
|
||||||
|
doc.start_link(handle)
|
||||||
|
else:
|
||||||
|
doc.start_link("/%s/%s" %
|
||||||
|
(obj_type.lower(), handle))
|
||||||
doc.write_text(col, 'Normal')
|
doc.write_text(col, 'Normal')
|
||||||
if self.__link[index]:
|
if obj_type:
|
||||||
doc.stop_link()
|
doc.stop_link()
|
||||||
doc.end_cell()
|
doc.end_cell()
|
||||||
doc.end_row()
|
doc.end_row()
|
||||||
|
@ -95,6 +95,9 @@ class Table(object):
|
|||||||
def row(self, *args):
|
def row(self, *args):
|
||||||
self.table.row(*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):
|
def get_html(self):
|
||||||
self.table.write(self.doc) # forces to htmllist
|
self.table.write(self.doc) # forces to htmllist
|
||||||
return str(self.doc.doc.htmllist[0])
|
return str(self.doc.doc.htmllist[0])
|
||||||
@ -147,6 +150,8 @@ def person_name_table(djperson, user):
|
|||||||
name.group_as,
|
name.group_as,
|
||||||
["No", "Yes"][sourceq],
|
["No", "Yes"][sourceq],
|
||||||
note)
|
note)
|
||||||
|
table.link('URL', "/person/%s/name/%s" %
|
||||||
|
(name.person.handle, name.id))
|
||||||
return table.get_html()
|
return table.get_html()
|
||||||
|
|
||||||
def person_source_table(djperson, user):
|
def person_source_table(djperson, user):
|
||||||
@ -379,7 +384,7 @@ def display_date(obj):
|
|||||||
if date_tuple:
|
if date_tuple:
|
||||||
gdate = GDate()
|
gdate = GDate()
|
||||||
gdate.unserialize(date_tuple)
|
gdate.unserialize(date_tuple)
|
||||||
return escape(_dd(gdate))
|
return _dd(gdate)
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@ -410,12 +415,12 @@ def make_name(name, user):
|
|||||||
if not surname:
|
if not surname:
|
||||||
surname = "[Missing]"
|
surname = "[Missing]"
|
||||||
if user.is_authenticated():
|
if user.is_authenticated():
|
||||||
return escape("%s, %s" % (surname, name.first_name))
|
return "%s, %s" % (surname, name.first_name)
|
||||||
else:
|
else:
|
||||||
if probably_alive(name.person.handle):
|
if probably_alive(name.person.handle):
|
||||||
return escape("%s, %s" % (surname, "[Living]"))
|
return "%s, %s" % (surname, "[Living]")
|
||||||
else:
|
else:
|
||||||
return escape("%s, %s" % (surname, name.first_name))
|
return "%s, %s" % (surname, name.first_name)
|
||||||
elif name: # name_set
|
elif name: # name_set
|
||||||
name = name.get(preferred=True)
|
name = name.get(preferred=True)
|
||||||
if name:
|
if name:
|
||||||
|
Loading…
Reference in New Issue
Block a user