Commit cdc18ba5 authored by Sebastien Robin's avatar Sebastien Robin Committed by Cédric Le Ninivin

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 e40489e4
...@@ -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
...@@ -49,9 +49,7 @@ ...@@ -49,9 +49,7 @@
<key> <string>trigger_method_id</string> </key> <key> <string>trigger_method_id</string> </key>
<value> <value>
<tuple> <tuple>
<string>_setResource.*</string> <string>_set.*</string>
<string>_setStartDate</string>
<string>_setStopDate</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -271,10 +271,20 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin): ...@@ -271,10 +271,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
...@@ -303,9 +313,7 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin): ...@@ -303,9 +313,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