Skip to content

Commit 1be07b6

Browse files
committed
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.
1 parent 1c76a3e commit 1be07b6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

roundup/admin.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -996,10 +996,16 @@ def get_prop_name(key, prop_name):
996996
if isinstance(property_obj,
997997
(hyperdb.Link, hyperdb.Multilink)):
998998
prop_class = getclass(property_obj.classname)
999-
key_prop_name = prop_class.key
1000-
if key_prop_name:
1001-
return prop_class.get(key, key_prop_name)
1002-
# None indicates that there is no key_prop
999+
label_prop_name = prop_class.labelprop(default_to_id=True)
1000+
if label_prop_name not in ['id', 'title']:
1001+
# Don't return 'id', its value is the key. If name is
1002+
# empty, the caller will use the classname with the key
1003+
# as the identifier: show "issue23" not "23(23)".
1004+
# Also don't use the title. It's too long in most
1005+
# cases. show: "issue23" not "please help me with
1006+
# samba use athentication issue(23)"
1007+
return prop_class.get(key, label_prop_name)
1008+
# None indicates that there is no viable label_prop
10031009
return None
10041010
return None
10051011

@@ -1072,7 +1078,7 @@ def format_set(data):
10721078
# .Hint read as: assignedto was admin(1)
10731079
# .Hint where assignedto is the property
10741080
# .Hint admin is the key name for value 1
1075-
_("%(prop)s was %(name)%(value)s)") % {
1081+
_("%(prop)s was %(name)s(%(value)s)") % {
10761082
"prop": prop, "name": name, "value": value })
10771083
else:
10781084
# use repr so strings with embedded \n etc. don't

0 commit comments

Comments
 (0)