[Mpuls-commits] r314 - in wasko/trunk: . waskaweb/lib waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Feb 27 12:24:09 CET 2009
Author: teichmann
Date: 2009-02-27 12:24:07 +0100 (Fri, 27 Feb 2009)
New Revision: 314
Modified:
wasko/trunk/ChangeLog.txt
wasko/trunk/waskaweb/lib/helpers.py
wasko/trunk/waskaweb/model/phases_factory.py
Log:
Shorten the variable descriptions in phase overview more intelligent.
Modified: wasko/trunk/ChangeLog.txt
===================================================================
--- wasko/trunk/ChangeLog.txt 2009-02-27 08:41:41 UTC (rev 313)
+++ wasko/trunk/ChangeLog.txt 2009-02-27 11:24:07 UTC (rev 314)
@@ -1,5 +1,17 @@
2009-02-27 Sascha L. Teichmann <teichmann at intevation.de>
+ * waskaweb/lib/helpers.py: New function space_short(s, n).
+ Shorten a string to n characters, but if the last char
+ of the shortend string is a none white space (= in the mid of
+ a word) the sting is extended to the next white space.
+ Shortend strings are postfixed with '...'.
+
+ * waskaweb/model/phases_factory.py: Use space_short() to
+ cut down the length of the descriptions of the listed variables.
+ The full description is given as a link title.
+
+2009-02-27 Sascha L. Teichmann <teichmann at intevation.de>
+
* waskaweb/model/navigation.py: Fixed bug when rendering
navigation with errors. All branches of the case where
open and uncloseable. Only the branches with error
Modified: wasko/trunk/waskaweb/lib/helpers.py
===================================================================
--- wasko/trunk/waskaweb/lib/helpers.py 2009-02-27 08:41:41 UTC (rev 313)
+++ wasko/trunk/waskaweb/lib/helpers.py 2009-02-27 11:24:07 UTC (rev 314)
@@ -167,6 +167,19 @@
return " ".join(out)
+def space_short(s, n):
+ L = len(s)
+ if (L - 3) <= n: return s
+ r = list(s[0:n])
+
+ while True:
+ R = len(r)
+ if R >= L or r[-1].isspace() or s[R].isspace(): break
+ r.append(s[R])
+
+ r.append(R < (L-3) and u'...' or s[L-(L-R):])
+ return u''.join(r)
+
def checkDate(value):
m = VALID_DATE.match(value)
if not m: return None
Modified: wasko/trunk/waskaweb/model/phases_factory.py
===================================================================
--- wasko/trunk/waskaweb/model/phases_factory.py 2009-02-27 08:41:41 UTC (rev 313)
+++ wasko/trunk/waskaweb/model/phases_factory.py 2009-02-27 11:24:07 UTC (rev 314)
@@ -35,6 +35,8 @@
from waskaweb.model.casedocument import WARNING
+from waskaweb.lib.helpers import space_short
+
from xml.sax.saxutils import quoteattr
import re
@@ -211,7 +213,7 @@
desc = description(v)
if len(desc) > 15:
title = quoteattr(u"Fehlende Angabe: %s" % desc)
- desc = escape(desc[0:15] + "...")
+ desc = escape(space_short(desc, 15))
else:
title = u'"Fehlende Angabe für diese Phase"'
desc = escape(desc)
More information about the Mpuls-commits
mailing list