Author: justi9
Date: 2008-10-09 16:31:20 -0400 (Thu, 09 Oct 2008)
New Revision: 2612
Modified:
mgmt/trunk/cumin/python/cumin/formats.py
mgmt/trunk/cumin/python/cumin/job.py
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/widgets.py
mgmt/trunk/cumin/python/cumin/widgets.strings
Log:
Some enhancements to our logic for shortening long names.
- Adds pre and post args (optional) to fmt_shorten
- Moves fmt_shorten out of get_object_title and instead to call sites
I also shortened some column titles so they wouldn't wrap.
Modified: mgmt/trunk/cumin/python/cumin/formats.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/formats.py 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/formats.py 2008-10-09 20:31:20 UTC (rev 2612)
@@ -109,12 +109,15 @@
def fmt_none_brief():
return "<span class=\"none\">–</span>"
-def fmt_shorten(string):
- if len(string) > 20:
- return string[:13] + "..." + string[-6:]
- else:
- return string
+def fmt_shorten(string, pre=16, post=0):
+ if len(string) > pre + post:
+ if post:
+ string = string[:pre] + "…" + string[-post:]
+ else:
+ string = string[:pre] + "…"
+ return string
+
def fmt_link(href, content, class_="", id="",
link_title=""):
return "<a %s href=\"%s\"%s%s>%s</a>" % \
(id and "id=\"%s\"" % id or "", href, class_ and
" class=\"%s\" " % class_ or " ",
Modified: mgmt/trunk/cumin/python/cumin/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.py 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/job.py 2008-10-09 20:31:20 UTC (rev 2612)
@@ -97,7 +97,7 @@
class ConcurrencyLimitsColumn(SqlTableColumn):
def render_title(self, session, data):
- return "Concurrency Limits"
+ return "Conc. Limits"
class CustomGroupColumn(SqlTableColumn):
def render_title(self, session, data):
@@ -108,11 +108,12 @@
if job_group:
branch = session.branch()
self.frame.show_job_group(branch, job_group).show_view(branch)
- return fmt_olink(branch, job_group, name=data[self.name])
+ name = fmt_shorten(data[self.name])
+ return fmt_olink(branch, job_group, name=name)
class CustomIdColumn(SqlTableColumn):
def render_title(self, session, data):
- return "Custom Id"
+ return "ID"
def render_content(self, session, data):
job = Identifiable(data["id"])
@@ -163,7 +164,8 @@
if data["submitter"]:
branch = session.branch()
self.frame.show_submitter(branch, submitter).show_view(branch)
- return fmt_olink(branch, submitter, name=data["submitter"])
+ name = fmt_shorten(data["submitter"])
+ return fmt_olink(branch, submitter, name=name)
else:
return data["scheduler"]
@@ -176,7 +178,8 @@
if data["scheduler"]:
branch = session.branch()
self.frame.show_scheduler(branch, scheduler).show_view(branch)
- return fmt_olink(branch, scheduler, name=data["scheduler"])
+ name = fmt_shorten(data["scheduler"])
+ return fmt_olink(branch, scheduler, name=name)
else:
return data["scheduler"]
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-10-09 20:31:20 UTC (rev 2612)
@@ -443,7 +443,7 @@
def get_object_title(self, session, object):
title = self.get_title(session)
name = self.get_object_name(object)
- return "%s '%s'" % (title, fmt_shorten(name))
+ return "%s '%s'" % (title, name)
def get_object_name(self, object):
return object.name
@@ -1620,7 +1620,7 @@
def get_object_title(self, session, limit):
title = self.get_title(session)
name = limit.id
- return "%s '%s'" % (title, fmt_shorten(name))
+ return "%s '%s'" % (title, name)
class SetLimit(CuminAction):
def show(self, session, job):
@@ -1673,7 +1673,7 @@
def get_object_title(self, session, group):
title = self.get_title(session)
name = group.get_id()
- return "%s '%s'" % (title, fmt_shorten(name))
+ return "%s '%s'" % (title, name)
def get_title(self, session):
return "Job Group"
@@ -2415,4 +2415,4 @@
writer.write("<data>")
writer.write(data)
writer.write("</data>")
-
\ No newline at end of file
+
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2008-10-09 20:31:20 UTC (rev 2612)
@@ -116,7 +116,7 @@
cls = self.app.model.get_class_by_object(obj)
- return cls.get_object_title(session, obj)
+ return fmt_shorten(cls.get_object_title(session, obj), 16, 4)
class CuminView(Widget):
def __init__(self, app, name):
Modified: mgmt/trunk/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.strings 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/widgets.strings 2008-10-09 20:31:20 UTC (rev 2612)
@@ -771,7 +771,7 @@
[CuminSummary.css]
div.CuminSummary {
- width: 32em;
+ width: 36em;
margin: 0 0 2em 0;
min-height: 6em;
}