Commit 1392357f authored by Jérome Perrin's avatar Jérome Perrin

ERP5ShortMessage: use a private/unrestricted method to search for gateways

User triggering action to send SMS does not have view permission on
Gateway
parent 839691ec
...@@ -60,7 +60,7 @@ class SMSTool(BaseTool): ...@@ -60,7 +60,7 @@ class SMSTool(BaseTool):
message_id and document_relative_url message_id and document_relative_url
""" """
gateway = self.find(gateway_reference) gateway = self._findGateway(gateway_reference)
message_id = gateway.send( message_id = gateway.send(
text=text, text=text,
...@@ -80,24 +80,25 @@ class SMSTool(BaseTool): ...@@ -80,24 +80,25 @@ class SMSTool(BaseTool):
security.declareProtected(ManagePortal, 'getMessageStatus') security.declareProtected(ManagePortal, 'getMessageStatus')
def getMessageStatus(self,message_id, gateway_reference='default'): def getMessageStatus(self,message_id, gateway_reference='default'):
gateway = self.find(gateway_reference) gateway = self._findGateway(gateway_reference)
return gateway.getMessageStatus(message_id) return gateway.getMessageStatus(message_id)
security.declarePublic('isSendByTitleAllowed') security.declarePublic('isSendByTitleAllowed')
def isSendByTitleAllowed(self, gateway_reference='default'): def isSendByTitleAllowed(self, gateway_reference='default'):
"""Define the support or not to use the title of the telephone instead of """Define the support or not to use the title of the telephone instead of
the number when send a message.""" the number when send a message."""
gateway = self.find(gateway_reference) gateway = self._findGateway(gateway_reference)
return gateway.isTitleMode() return gateway.isTitleMode()
security.declarePublic('find') def _findGateway(self, gateway_reference='default'):
def find(self,gateway_reference='default'): """Search the gateway by its reference"""
"""Search the gateway by his reference"""
result = self.searchFolder(reference=gateway_reference) result = self.getPortalObject().portal_catalog.unrestrictedSearchResults(
if len(result) > 0: parent_uid=self.getUid(),
return result[0].getObject() reference=gateway_reference)
else: if result:
raise ValueError, "Impossible to find gateway with reference %s" % gateway_reference result, = result # ensure only one gateway with this reference
return result.getObject()
raise ValueError("Impossible to find gateway with reference %s" % gateway_reference)
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