Commit a3d57401 authored by Alexandre Boeglin's avatar Alexandre Boeglin

* updateAppliedRule rule_id parameter renamed to rule_reference, as this is

    what the method now expects
* fix coding style (whitespace after comma)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17555 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ce2310fb
......@@ -654,36 +654,36 @@ class Delivery(XMLObject, ImmobilisationDelivery):
##########################################################################
# Applied Rule stuff
def updateAppliedRule(self, rule_id,force=0,**kw):
def updateAppliedRule(self, rule_reference, force=0, **kw):
"""
Create a new Applied Rule if none is related, or call expand
on the existing one.
The chosen applied rule will be the validated rule with reference ==
rule_id, and the higher version number.
rule_reference, and the higher version number.
If no rule is found, simply pass rule_id to _createAppliedRule, as we
did previously.
If no rule is found, simply pass rule_reference to _createAppliedRule,
to keep compatibility vith the previous behaviour
"""
if rule_id is None:
if rule_reference is None:
return
portal_rules = getToolByName(self, 'portal_rules')
res = portal_rules.searchFolder(reference=rule_id,
res = portal_rules.searchFolder(reference=rule_reference,
validation_state="validated", sort_on='version',
sort_order='descending') # XXX validated is Hardcoded !
if len(res) > 0:
rule_id = res[0].getId()
else:
rule_id = rule_reference
if (self.getSimulationState() not in \
if (self.getSimulationState() not in
self.getPortalDraftOrderStateList()):
# Nothing to do if we are already simulated
self._createAppliedRule(rule_id,force=force,**kw)
self._createAppliedRule(rule_id, force=force, **kw)
def _createAppliedRule(self, rule_id,force=0,activate_kw=None,**kw):
def _createAppliedRule(self, rule_id, force=0, activate_kw=None, **kw):
"""
Create a new Applied Rule is none is related, or call expand
on the existing one.
......@@ -695,7 +695,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
return
# Otherwise, expand
# Look up if existing applied rule
my_applied_rule_list = self.getCausalityRelatedValueList(\
my_applied_rule_list = self.getCausalityRelatedValueList(
portal_type='Applied Rule')
my_applied_rule = None
if len(my_applied_rule_list) == 0:
......@@ -713,7 +713,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
my_applied_rule.setCausalityValue(self)
# We must make sure this rule is indexed
# now in order not to create another one later
my_applied_rule.reindexObject(activate_kw=activate_kw,**kw)
my_applied_rule.reindexObject(activate_kw=activate_kw, **kw)
elif len(my_applied_rule_list) == 1:
# Re expand the rule if possible
my_applied_rule = my_applied_rule_list[0]
......@@ -725,15 +725,14 @@ class Delivery(XMLObject, ImmobilisationDelivery):
expand_activate_kw = {}
if my_applied_rule is not None:
my_applied_rule_id = my_applied_rule.getId()
expand_activate_kw['after_path_and_method_id'] = \
(my_applied_rule.getPath(),\
expand_activate_kw['after_path_and_method_id'] = (
my_applied_rule.getPath(),
['immediateReindexObject', 'recursiveImmediateReindexObject'])
# We are now certain we have a single applied rule
# It is time to expand it
self.activate( activate_kw=activate_kw,
**expand_activate_kw
).expand(applied_rule_id=my_applied_rule_id,force=force,
activate_kw=activate_kw,**kw)
self.activate(activate_kw=activate_kw, **expand_activate_kw).expand(
applied_rule_id=my_applied_rule_id, force=force,
activate_kw=activate_kw, **kw)
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule_id=None, force=0, activate_kw=None,**kw):
......
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