allow a cell in table to not have a link; put buttons in cell for children
svn: r20052
This commit is contained in:
parent
3da425b6c8
commit
95a604f2c6
@ -169,7 +169,7 @@ class SimpleTable(object):
|
||||
retval.append(item[0])
|
||||
link = (item[1], item[2:])
|
||||
else:
|
||||
retval.append(str(item))
|
||||
retval.append(item)
|
||||
if (self._link_col == col or link is None):
|
||||
if hasattr(item, "get_url"):
|
||||
link = ("url", item.get_url())
|
||||
@ -219,7 +219,9 @@ class SimpleTable(object):
|
||||
for col in row:
|
||||
doc.start_cell('TableDataCell', span=1)
|
||||
obj_type, handle = None, None
|
||||
if isinstance(self._link_col, tuple):
|
||||
if hasattr(col, "get_url"):
|
||||
obj_type, handle = "URL", col.get_url()
|
||||
elif isinstance(self._link_col, tuple):
|
||||
obj_type, handle = self._link_col
|
||||
elif isinstance(self._link_col, list):
|
||||
obj_type, handle = self._link_col[index]
|
||||
@ -228,12 +230,13 @@ class SimpleTable(object):
|
||||
######
|
||||
if obj_type:
|
||||
if obj_type.lower() == "url":
|
||||
doc.start_link(handle)
|
||||
if handle:
|
||||
doc.start_link(handle)
|
||||
else:
|
||||
doc.start_link("/%s/%s" %
|
||||
(obj_type.lower(), handle))
|
||||
doc.write_text(col, 'Normal')
|
||||
if obj_type:
|
||||
doc.write_text(str(col), 'Normal')
|
||||
if obj_type and handle:
|
||||
doc.stop_link()
|
||||
doc.end_cell()
|
||||
doc.end_row()
|
||||
|
@ -826,10 +826,20 @@ def tag_reference_table(obj, user, act):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
class Link(object):
|
||||
def __init__(self, string, url=None):
|
||||
self.string = string
|
||||
self.url = url
|
||||
def get_url(self):
|
||||
return self.url
|
||||
def __str__(self):
|
||||
return self.string
|
||||
|
||||
def children_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("children_table")
|
||||
table.columns(
|
||||
"",
|
||||
_("#"),
|
||||
_("ID"),
|
||||
_("Name"),
|
||||
@ -838,7 +848,7 @@ def children_table(obj, user, act, url=None, *args):
|
||||
_("Maternal"),
|
||||
_("Birth Date"),
|
||||
)
|
||||
table.column_widths = [3] + [98/6] * 6
|
||||
#table.column_widths = [3] + [98/6] * 6
|
||||
|
||||
family = obj
|
||||
obj_type = ContentType.objects.get_for_model(family)
|
||||
@ -849,7 +859,8 @@ def children_table(obj, user, act, url=None, *args):
|
||||
for childref in childrefs:
|
||||
child = childref.ref_object
|
||||
if user.is_authenticated():
|
||||
table.row(str(count),
|
||||
table.row(Link("[[x]][[^]][[v]]"),
|
||||
str(count),
|
||||
"[%s]" % child.gramps_id,
|
||||
render_name(child, user),
|
||||
child.gender_type,
|
||||
@ -875,6 +886,9 @@ def children_table(obj, user, act, url=None, *args):
|
||||
count += 1
|
||||
table.links(links)
|
||||
retval += table.get_html()
|
||||
retval = retval.replace("[[x]]", make_button("x", "/person/remove/family/%s" % family.handle))
|
||||
retval = retval.replace("[[^]]", make_button("^", "/person/up/family/%s" % family.handle))
|
||||
retval = retval.replace("[[v]]", make_button("v", "/person/down/family/%s" % family.handle))
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add New Person as Child"), (url.replace("$act", "add") % args))
|
||||
retval += make_button(_("Add Existing Person as Child"), (url.replace("$act", "share") % args))
|
||||
|
Loading…
Reference in New Issue
Block a user