Mercurial > p > roundup > code
changeset 7800:2d4684e4702d
fix: enhancement to history command output and % template fix.
Rather than using the key field, use the label field for descriptions.
Call cls.labelprop(default_to_id=True) so it returns id rather than
the first sorted property name.
If labelprop() returns 'id' or 'title', we return nothing. 'id' means
there is no label set and no properties named 'name' or 'title'. So
have the caller do whatever it wants (prepend classname for example)
when there is no human readable name. This prevents %(name)s%(key)s
from producing: 23(23).
Also don't accept the 'title' property. Titles can be too
long. Arguably we could: '%(name)20s' to limit the title
length. However without ellipses or something truncating the title
might be confusing. So again pretend there is no human readable name.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 12 Mar 2024 11:52:17 -0400 |
| parents | 10da9e12c10f |
| children | af898d1d66dc |
| files | roundup/admin.py |
| diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/admin.py Sun Mar 10 23:12:54 2024 -0400 +++ b/roundup/admin.py Tue Mar 12 11:52:17 2024 -0400 @@ -996,10 +996,16 @@ if isinstance(property_obj, (hyperdb.Link, hyperdb.Multilink)): prop_class = getclass(property_obj.classname) - key_prop_name = prop_class.key - if key_prop_name: - return prop_class.get(key, key_prop_name) - # None indicates that there is no key_prop + label_prop_name = prop_class.labelprop(default_to_id=True) + if label_prop_name not in ['id', 'title']: + # Don't return 'id', its value is the key. If name is + # empty, the caller will use the classname with the key + # as the identifier: show "issue23" not "23(23)". + # Also don't use the title. It's too long in most + # cases. show: "issue23" not "please help me with + # samba use athentication issue(23)" + return prop_class.get(key, label_prop_name) + # None indicates that there is no viable label_prop return None return None @@ -1072,7 +1078,7 @@ # .Hint read as: assignedto was admin(1) # .Hint where assignedto is the property # .Hint admin is the key name for value 1 - _("%(prop)s was %(name)%(value)s)") % { + _("%(prop)s was %(name)s(%(value)s)") % { "prop": prop, "name": name, "value": value }) else: # use repr so strings with embedded \n etc. don't
