Commit 48203562 authored by Francois Blackburn's avatar Francois Blackburn

outcall: add method to update dialpattern attr

When the extension is already associated to outcall, something we want
only to update dialpattern attributes
parent bb0e499d
......@@ -122,6 +122,14 @@ class Outcall(Base):
extension.typeval = '0'
self._fix_context()
def update_extension_association(self, extension, **kwargs):
for dialpattern in self.dialpatterns:
if extension == dialpattern.extension:
dialpattern.strip_digits = kwargs.get('strip_digits', dialpattern.strip_digits)
dialpattern.prefix = kwargs.get('prefix', dialpattern.prefix)
dialpattern.external_prefix = kwargs.get('external_prefix', dialpattern.external_prefix)
dialpattern.caller_id = kwargs.get('caller_id', dialpattern.caller_id)
def _fix_context(self):
for extension in self.extensions:
self.context = extension.context
......
......@@ -498,3 +498,23 @@ class TestAssociateExtension(DAOTestCase):
row = self.session.query(DialPattern).first()
assert_that(row, none())
def test_update_extension_association(self):
outcall_row = self.add_outcall()
extension_row = self.add_extension()
outcall_row.associate_extension(extension_row, caller_id='toto', prefix='1')
outcall_row.update_extension_association(extension_row,
caller_id='tata',
external_prefix='123')
rows = self.session.query(Extension).all()
assert_that(rows, contains(extension_row))
rows = self.session.query(DialPattern).all()
assert_that(rows, contains(has_properties(
caller_id='tata',
external_prefix='123',
prefix='1',
strip_digits=0
)))
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