Mercurial > p > roundup > code
comparison roundup/admin.py @ 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 | 7c0a8088b053 |
comparison
equal
deleted
inserted
replaced
| 7799:10da9e12c10f | 7800:2d4684e4702d |
|---|---|
| 994 # the property has been removed from the schema. | 994 # the property has been removed from the schema. |
| 995 return None | 995 return None |
| 996 if isinstance(property_obj, | 996 if isinstance(property_obj, |
| 997 (hyperdb.Link, hyperdb.Multilink)): | 997 (hyperdb.Link, hyperdb.Multilink)): |
| 998 prop_class = getclass(property_obj.classname) | 998 prop_class = getclass(property_obj.classname) |
| 999 key_prop_name = prop_class.key | 999 label_prop_name = prop_class.labelprop(default_to_id=True) |
| 1000 if key_prop_name: | 1000 if label_prop_name not in ['id', 'title']: |
| 1001 return prop_class.get(key, key_prop_name) | 1001 # Don't return 'id', its value is the key. If name is |
| 1002 # None indicates that there is no key_prop | 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 | |
| 1003 return None | 1009 return None |
| 1004 return None | 1010 return None |
| 1005 | 1011 |
| 1006 def get_prop_class(prop_name): | 1012 def get_prop_class(prop_name): |
| 1007 # getclass and classname from enclosing method | 1013 # getclass and classname from enclosing method |
| 1070 if name: | 1076 if name: |
| 1071 result.append( | 1077 result.append( |
| 1072 # .Hint read as: assignedto was admin(1) | 1078 # .Hint read as: assignedto was admin(1) |
| 1073 # .Hint where assignedto is the property | 1079 # .Hint where assignedto is the property |
| 1074 # .Hint admin is the key name for value 1 | 1080 # .Hint admin is the key name for value 1 |
| 1075 _("%(prop)s was %(name)%(value)s)") % { | 1081 _("%(prop)s was %(name)s(%(value)s)") % { |
| 1076 "prop": prop, "name": name, "value": value }) | 1082 "prop": prop, "name": name, "value": value }) |
| 1077 else: | 1083 else: |
| 1078 # use repr so strings with embedded \n etc. don't | 1084 # use repr so strings with embedded \n etc. don't |
| 1079 # generate newlines in output. Try to keep each | 1085 # generate newlines in output. Try to keep each |
| 1080 # journal entry on 1 line. | 1086 # journal entry on 1 line. |
