Commit 590060ec authored by Tres Seaver's avatar Tres Seaver

Launchpad #142350: Display description for properties as row title, if present.

parent e57c2618
......@@ -8,6 +8,9 @@ Zope Changes
Bugs Fixed
- Launchpad #142350: Display description for properties as row title,
if present.
- Launchpad #200007: DateTime(anotherDateTime) now preserves the
timezone.
......
......@@ -258,6 +258,16 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
return p.get('label', id)
return id
security.declareProtected(access_contents_information,
'propertyDescription')
def propertyDescription(self, id):
"""Return a description for the given property id
"""
for p in self._properties:
if p['id'] == id:
return p.get('description', '')
return id
security.declareProtected(access_contents_information, 'propdict')
def propdict(self):
dict={}
......
......@@ -61,8 +61,9 @@ property values, edit the values and click "Save Changes".
</tr>
<dtml-in propertyMap mapping>
<dtml-let type="not _.has_key('type') and 'string' or type">
<tr>
<dtml-let type="not _.has_key('type') and 'string' or type"
pdesc="propertyDescription(id)">
<tr title="&dtml-pdesc;">
<td align="left" valign="top" width="16">
<dtml-if "'d' in _['sequence-item'].get('mode', 'awd')">
<input type="checkbox" name="_ids:<dtml-var "REQUEST['management_page_charset_tag']">string:list" value="&dtml-id;"
......
......@@ -21,10 +21,12 @@ import unittest
class TestPropertyManager(unittest.TestCase):
"""Property management tests."""
def _makeOne(self, *args, **kw):
def _getTargetClass(self):
from OFS.PropertyManager import PropertyManager
return PropertyManager
return PropertyManager(*args, **kw)
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
def test_z3interfaces(self):
from OFS.interfaces import IPropertyManager
......@@ -52,6 +54,40 @@ class TestPropertyManager(unittest.TestCase):
self.failUnless(type(inst.getProperty('prop2')) == type(()))
self.failUnless(type(inst.prop2) == type(()))
def test_propertyLabel_no_label_falls_back_to_id(self):
class NoLabel(self._getTargetClass()):
_properties = (
{'id': 'no_label', 'type': 'string'},
)
inst = NoLabel()
self.assertEqual(inst.propertyLabel('no_label'), 'no_label')
def test_propertyLabel_with_label(self):
class WithLabel(self._getTargetClass()):
_properties = (
{'id': 'with_label', 'type': 'string', 'label': 'With Label'},
)
inst = WithLabel()
self.assertEqual(inst.propertyLabel('with_label'), 'With Label')
def test_propertyDescription_no_description_falls_back_to_id(self):
class NoDescription(self._getTargetClass()):
_properties = (
{'id': 'no_description', 'type': 'string'},
)
inst = NoDescription()
self.assertEqual(inst.propertyDescription('no_description'), '')
def test_propertyDescription_with_description(self):
class WithDescription(self._getTargetClass()):
_properties = (
{'id': 'with_description', 'type': 'string',
'description': 'With Description'},
)
inst = WithDescription()
self.assertEqual(inst.propertyDescription('with_description'),
'With Description')
class TestPropertySheet(unittest.TestCase):
"""Property management tests."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment