Commit 0ebcacc1 authored by Sebastien Robin's avatar Sebastien Robin Committed by Your Name

mrp: use predicates to find out transformations corresponding to a context

Since predicate could match any property, the transformation corresponding to a line might
change upon the change of any property. Make sure the interaction take into account any property
parent 958a5b30
...@@ -5,14 +5,9 @@ if include_empty: ...@@ -5,14 +5,9 @@ if include_empty:
result.append(('','')) result.append(('',''))
if resource is not None: if resource is not None:
portal = context.getPortalObject()
kw = {'validation_state': '!=invalidated'} if skip_invalidated else {} kw = {'validation_state': '!=invalidated'} if skip_invalidated else {}
result.extend((transformation.title, transformation.relative_url) result.extend([(x.getTitle(), x.getRelativeUrl()) for x in resource.searchTransformationList(context,
for transformation in portal.portal_catalog( **kw)])
select_list=('title', 'relative_url'), portal = context.getPortalObject()
portal_type=portal.getPortalTransformationTypeList(),
strict_resource_uid=resource.getUid(),
sort_on=('title', 'relative_url'),
**kw))
return result return result
...@@ -56,9 +56,7 @@ ...@@ -56,9 +56,7 @@
<key> <string>method_id</string> </key> <key> <string>method_id</string> </key>
<value> <value>
<list> <list>
<string>_setResource.*</string> <string>_set.*</string>
<string>_setStartDate</string>
<string>_setStopDate</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -270,10 +270,20 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin): ...@@ -270,10 +270,20 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
def getDefaultResourceValue(self): def getDefaultResourceValue(self):
return self return self
security.declareProtected(Permissions.AccessContentsInformation,
'searchTransformationList')
def searchTransformationList(self, context, **kw):
"""
Find all transformations matching given context
"""
portal = self.getPortalObject()
return portal.portal_domains.searchPredicateList(context,
portal_type=portal.getPortalTransformationTypeList(),
**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getDefaultTransformationValue') 'getDefaultTransformationValue')
def getDefaultTransformationValue(self, context=None): def getDefaultTransformationValue(self, context=None, **kw):
""" """
If context is None, returns the first available transformation that If context is None, returns the first available transformation that
use self as a Resource. If there are several candidates, return the use self as a Resource. If there are several candidates, return the
...@@ -302,9 +312,7 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin): ...@@ -302,9 +312,7 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
if method is not None: if method is not None:
return method(context) return method(context)
transformation_list = self.portal_domains.searchPredicateList(context, transformation_list = self.searchTransformationList(context, **kw)
portal_type=self.getPortalObject().getPortalTransformationTypeList(),
limit=1)
if len(transformation_list) > 0: if len(transformation_list) > 0:
return transformation_list[0] return transformation_list[0]
......
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