From 0adf58da2bfdf2b228fcd4e13fe7e6a123cf890d Mon Sep 17 00:00:00 2001 From: Levin Zimmermann <levin.zimmermann@nexedi.com> Date: Tue, 12 Jul 2022 11:34:44 +0200 Subject: [PATCH] fixup! AlarmTool: handle automatic solve with alarms owned by system user --- product/ERP5/Document/Alarm.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/product/ERP5/Document/Alarm.py b/product/ERP5/Document/Alarm.py index cace26e40b..5a11cc8545 100644 --- a/product/ERP5/Document/Alarm.py +++ b/product/ERP5/Document/Alarm.py @@ -29,6 +29,7 @@ from compiler.consts import CO_VARKEYWORDS from DateTime import DateTime +from random import getrandbits from AccessControl import ClassSecurityInfo, Unauthorized from AccessControl.SecurityManagement import getSecurityManager, \ setSecurityManager, newSecurityManager @@ -103,7 +104,7 @@ class Alarm(XMLObject, PeriodicityMixin): return '%s_%s' % (self.getRelativeUrl(), id) security.declareProtected(Permissions.AccessContentsInformation, 'activeSense') - def activeSense(self, fixit=0, params=None): + def activeSense(self, fixit=0, activate_kw=(), params=None): """ This method launches the sensing process as activities. It is intended to launch a very long process made @@ -113,11 +114,10 @@ class Alarm(XMLObject, PeriodicityMixin): The result of the sensing process can be obtained by invoking the sense method or by requesting a report. """ - portal_membership = self.getPortalObject().portal_membership - if fixit or not self.getEnabled(): - checkPermission = portal_membership.checkPermission - if not checkPermission(Permissions.ManagePortal, self): - raise Unauthorized('fixing problems or activating a disabled alarm is not allowed') + activate_kw = dict(activate_kw) + + if (fixit or not self.getEnabled()) and not self.getPortalObject().portal_membership.checkPermission(Permissions.ManagePortal, self): + raise Unauthorized('fixing problems or activating a disabled alarm is not allowed') # Use UnrestrictedMethod, so that the behavior would not # change even if this method is invoked by random users. -- 2.30.9