Commit cf939d9a authored by Sebastien Robin's avatar Sebastien Robin Committed by Titouan Soulard

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 6b4e028d
......@@ -5,14 +5,9 @@ if include_empty:
result.append(('',''))
if resource is not None:
portal = context.getPortalObject()
kw = {'validation_state': '!=invalidated'} if skip_invalidated else {}
result.extend((transformation.title, transformation.relative_url)
for transformation in portal.portal_catalog(
select_list=('title', 'relative_url'),
portal_type=portal.getPortalTransformationTypeList(),
strict_resource_uid=resource.getUid(),
sort_on=('title', 'relative_url'),
**kw))
result.extend([(x.getTitle(), x.getRelativeUrl()) for x in resource.searchTransformationList(context,
**kw)])
portal = context.getPortalObject()
return result
......@@ -49,9 +49,7 @@
<key> <string>trigger_method_id</string> </key>
<value>
<tuple>
<string>_setResource.*</string>
<string>_setStartDate</string>
<string>_setStopDate</string>
<string>_set.*</string>
</tuple>
</value>
</item>
......
......@@ -271,10 +271,20 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
def getDefaultResourceValue(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,
'getDefaultTransformationValue')
def getDefaultTransformationValue(self, context=None):
def getDefaultTransformationValue(self, context=None, **kw):
"""
If context is None, returns the first available transformation that
use self as a Resource. If there are several candidates, return the
......@@ -303,9 +313,7 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
if method is not None:
return method(context)
transformation_list = self.portal_domains.searchPredicateList(context,
portal_type=self.getPortalObject().getPortalTransformationTypeList(),
limit=1)
transformation_list = self.searchTransformationList(context, **kw)
if len(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