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

code factorization for security permissions in Solvers

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