Author: croberts
Date: 2011-05-23 20:24:43 +0000 (Mon, 23 May 2011)
New Revision: 4778
Modified:
trunk/cumin/python/cumin/grid/submission.py
trunk/cumin/python/cumin/objectframe.py
Log:
For BZ
https://bugzilla.redhat.com/show_bug.cgi?id=699732 . We are now truncating the
submission name at 100 characters when displaying it in the Submission selection table, as
a breadcrumb or as a heading. The truncation will result in "..." being shown
at the end to indicate a truncation. This should avoid the page getting very ugly when
submission names are very large.
Modified: trunk/cumin/python/cumin/grid/submission.py
===================================================================
--- trunk/cumin/python/cumin/grid/submission.py 2011-05-23 15:45:13 UTC (rev 4777)
+++ trunk/cumin/python/cumin/grid/submission.py 2011-05-23 20:24:43 UTC (rev 4778)
@@ -88,7 +88,7 @@
cls = app.model.com_redhat_grid.JobServer
self.add_filter(self.pool, cls.Pool)
- col = ObjectLinkColumn(app, "name", self.cls.Name, self.cls._id,
frame)
+ col = self.PoolSubmissionObjectLinkColumn(app, "name", self.cls.Name,
self.cls._id, frame)
self.insert_column(0, col)
self.add_search_filter(col)
@@ -111,6 +111,14 @@
def do_enter(self, session, obj, form_session):
pool = self.parent.pool.get(session)
self.form.pool_name.set(form_session, pool.Pool)
+
+ class PoolSubmissionObjectLinkColumn(ObjectLinkColumn):
+ def render_cell_content(self, session, record):
+ retval = len(record) > 0 and record[self.field.index] or ""
+ if(len(record[self.field.index]) > 100):
+ retval = record[self.field.index][:100] + "..." #indicate that
we truncated the name
+ return retval
+
class PoolSubmissionJoinSelector(PoolSubmissionSelector):
def __init__(self, app, name, pool):
Modified: trunk/cumin/python/cumin/objectframe.py
===================================================================
--- trunk/cumin/python/cumin/objectframe.py 2011-05-23 15:45:13 UTC (rev 4777)
+++ trunk/cumin/python/cumin/objectframe.py 2011-05-23 20:24:43 UTC (rev 4778)
@@ -233,8 +233,20 @@
links.append(self.link.render(session, frame))
- return " › ".join(reversed(links))
-
+ trimmed_links = list()
+ text_matcher = re.compile('<a.*?>(.*?)</a>')
+ for onelink in links:
+ new_link = onelink
+ #get just the text that we will be displaying to truncate
+ result = text_matcher.search(onelink)
+ if(result.group(1) and len(result.group(1)) > 100):
+ origText = result.group(1)
+ newText = result.group(1)[:100] + "...'"
+ new_link = onelink.replace(origText, newText, 1)
+ trimmed_links.append(new_link)
+
+ return " › ".join(reversed(trimmed_links))
+
class ObjectViewContextLink(Link):
def __init__(self, app, name):
super(ObjectViewContextLink, self).__init__(app, name)
@@ -261,7 +273,11 @@
return self.frame.icon_href
def render_title(self, session):
- return self.parent.render_title(session)
+ retval = self.parent.render_title(session)
+ if(len(retval) > 100):
+ retval = retval[:100] + "..."
+ return retval
+
class ObjectViewSummary(ObjectViewChild):
def __init__(self, app, name, object):