Commit 9d710981 authored by Nicolas Wavrant's avatar Nicolas Wavrant

code factorization for security permissions in Solvers

parent e447832e
......@@ -29,7 +29,6 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5.mixin.solver import ConfigurablePropertySolverMixin
class AcceptSolver(ConfigurablePropertySolverMixin):
......@@ -42,10 +41,7 @@ class AcceptSolver(ConfigurablePropertySolverMixin):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# ISolver Implementation
security.declarePrivate('solve')
@UnrestrictedMethod
def solve(self, activate_kw=None):
def _solve(self, activate_kw=None):
"""
Adopt new property to simulation movements, with keeping the
original one recorded.
......
......@@ -29,7 +29,6 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5.mixin.solver import ConfigurablePropertySolverMixin
class AdoptSolver(ConfigurablePropertySolverMixin):
......@@ -42,10 +41,7 @@ class AdoptSolver(ConfigurablePropertySolverMixin):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# ISolver Implementation
security.declarePrivate('solve')
@UnrestrictedMethod
def solve(self, activate_kw=None):
def _solve(self, activate_kw=None):
"""
Adopt new property to movements or deliveries.
"""
......
......@@ -31,7 +31,6 @@ import zope.interface
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.mixin.solver import SolverMixin
from Products.ERP5.mixin.configurable import ConfigurableMixin
......@@ -65,10 +64,7 @@ class ItemListSplitSolver(SolverMixin, ConfigurableMixin, XMLObject):
interfaces.IConfigurable,
)
# ISolver Implementation
security.declarePrivate('solve')
@UnrestrictedMethod
def solve(self, activate_kw=None):
def _solve(self, activate_kw=None):
"""This method create new movement based on difference of aggregate sets.
It supports only removed items.
Quantity divergence is also solved with sum of aggregated quantities stored
......
......@@ -58,10 +58,7 @@ class MovementSplitSolver(SolverMixin, ConfigurableMixin, XMLObject):
interfaces.IConfigurable,
)
# ISolver Implementation
security.declarePrivate('solve')
@UnrestrictedMethod
def solve(self, activate_kw=None):
def _solve(self, activate_kw=None):
"""
This method splits a Delivery and move movements in to a new
Delivery. Splitting is done by duplicating the Delivery, removing
......
......@@ -31,7 +31,6 @@ import zope.interface
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Globals import PersistentMapping
from Products.ERP5.mixin.solver import SolverMixin
......@@ -67,9 +66,7 @@ class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject):
)
# ISolver Implementation
security.declarePrivate('solve')
@UnrestrictedMethod
def solve(self, activate_kw=None):
def _solve(self, activate_kw=None):
"""
"""
configuration_dict = self.getConfigurationPropertyDict()
......
......@@ -29,7 +29,6 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5.Document.AcceptSolver import AcceptSolver
class TradeModelSolver(AcceptSolver):
......@@ -58,10 +57,7 @@ class TradeModelSolver(AcceptSolver):
# Declarative interfaces
zope.interface.implements(interfaces.ISolver,)
# ISolver Implementation
security.declarePrivate('solve')
@UnrestrictedMethod
def solve(self, activate_kw=None):
def _solve(self, activate_kw=None):
"""
Adopt new values to simulation movements, with keeping the original
one recorded, and then update Trade Model related lines accordingly.
......
......@@ -30,7 +30,6 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5.Document.AcceptSolver import AcceptSolver
class UnifySolver(AcceptSolver):
......@@ -90,10 +89,7 @@ class UnifySolver(AcceptSolver):
simulation_movement_list.append(simulation_movement)
return simulation_movement_list
# ISolver Implementation
security.declarePrivate('solve')
@UnrestrictedMethod
def solve(self, activate_kw=None):
def _solve(self, activate_kw=None):
"""
Adopt new property value to simulation movements and their deliveries,
while keeping the original one recorded.
......
......@@ -30,6 +30,7 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.UnrestrictedMethod import super_user
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.mixin.configurable import ConfigurableMixin
......@@ -44,7 +45,14 @@ class SolverMixin(object):
# Declarative interfaces
zope.interface.implements(interfaces.ISolver,)
def _solve(self, activate_kw=None):
raise NotImplementedError
# Implementation of ISolver
security.declarePrivate('solve')
def solve(self, activate_kw=None):
with super_user():
self._solve(activate_kw=activate_kw)
def getPortalTypeValue(self):
return self.getPortalObject().portal_solvers._getOb(self.getPortalType())
......
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