From b396f23e65cab21e45eb41c8a33bbe16349832b3 Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Mon, 31 Oct 2005 12:52:43 +0000 Subject: [PATCH] Support for turning off activities git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4187 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/CMFActivity/ActivityTool.py | 36 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/product/CMFActivity/ActivityTool.py b/product/CMFActivity/ActivityTool.py index b5311bc9ff..74772f6704 100755 --- a/product/CMFActivity/ActivityTool.py +++ b/product/CMFActivity/ActivityTool.py @@ -269,28 +269,48 @@ class ActivityTool (Folder, UniqueObject): for activity in activity_list: activity.initialize(self) is_initialized = 1 + + security.declareProtected(Permissions.manage_properties, 'isSubscribed') + def isSubscribed(self): + """" + return True, if we are subscribed to TimerService. + Otherwise return False. + """ + service = getTimerService(self) + if not service: + LOG('ActivityTool', INFO, 'TimerService not available') + return False + + path = '/'.join(self.getPhysicalPath()) + if path in service.lisSubscriptions(): + return True + return False security.declareProtected(Permissions.manage_properties, 'subscribe') def subscribe(self): """ subscribe to the global Timer Service """ service = getTimerService(self) + url = '%s/manageLoadBalancing?manage_tabs_message=' %self.absolute_url() if not service: LOG('ActivityTool', INFO, 'TimerService not available') - return - - service.subscribe(self) - return "Subscribed to Timer Service" + url += urllib.quote('TimerService not available') + else: + service.subscribe(self) + url += urllib.quote("Subscribed to Timer Service") + return self.REQUEST.RESPONSE.redirect(url) security.declareProtected(Permissions.manage_properties, 'unsubscribe') def unsubscribe(self): """ unsubscribe from the global Timer Service """ service = getTimerService(self) + url = '%s/manageLoadBalancing?manage_tabs_message=' %self.absolute_url() if not service: LOG('ActivityTool', INFO, 'TimerService not available') - return - - service.unsubscribe(self) - return "Unsubscribed from Timer Service" + url += urllib.quote('TimerService not available') + else: + service.unsubscribe(self) + url += urllib.quote("Unsubscribed from Timer Service") + return self.REQUEST.RESPONSE.redirect(url) def manage_beforeDelete(self, item, container): self.unsubscribe() -- 2.30.9