Commit 1cfa9bb8 authored by Laurent Meiller's avatar Laurent Meiller 🐊

Merge branch...

Merge branch '3162-as-a-user-with-ua-i-should-have-only-one-presence-state-displayed-for-other-users' into 'master'

3162 as a user with ua i should have only one presence state displayed for other users

See merge request !60
parents 00b36b25 2e0df872
xivo-dao (2020.07.00) xivo-electra; urgency=medium
* 3162 As a user with UA I should have only one presence state displayed for other users
-- Tomas Taraba <ttaraba@avencall.com> Thu, 02 Apr 2020 14:57:19 +0200
xivo-dao (2019.12.07) xivo-deneb; urgency=medium
* 2989 Include agentid in user search api
......
......@@ -41,7 +41,7 @@ from xivo_dao.alchemy.func_key_mapping import FuncKeyMapping
from xivo_dao.alchemy.callfiltermember import Callfiltermember
from xivo_dao.alchemy.callfilter import Callfilter
from xivo_dao.resources.func_key.model import Hint
from xivo_dao.resources.func_key.model import Hint, HintWithOptions
def _find_extenfeatures(session, typeval):
......@@ -90,7 +90,8 @@ def user_hints(session, context):
(LineFeatures.protocol == 'sccp', literal_column("'SCCP/'") + SCCPLine.name),
(LineFeatures.protocol == 'custom', UserCustom.interface)
]).label('argument'),
LineFeatures.configregistrar.label('mediaserver'))
LineFeatures.configregistrar.label('mediaserver'),
UserSIP._options.label('options'))
.join(UserLine.userfeatures)
.join(UserLine.linefeatures)
.outerjoin(UserSIP,
......@@ -114,10 +115,11 @@ def user_hints(session, context):
.filter(Extension.context == context)
.filter(UserFeatures.enablehint == 1))
return tuple(Hint(user_id=row.user_id,
extension=row.extension,
argument=row.argument,
mediaserver=row.mediaserver)
return tuple(HintWithOptions(user_id=row.user_id,
extension=row.extension,
argument=row.argument,
mediaserver=row.mediaserver,
options=row.options)
for row in query)
......@@ -219,7 +221,7 @@ def bsfilter_hints(session, context):
bsfilter_extension = clean_extension(_find_extenfeatures(session, 'bsfilter'))
query = (session.query(sql.cast(FuncKeyDestBSFilter.filtermember_id, Unicode).label('argument'),
LineFeatures.configregistrar.label('mediaserver'))
LineFeatures.configregistrar.label('mediaserver'))
.join(Callfiltermember,
Callfiltermember.id == FuncKeyDestBSFilter.filtermember_id)
.join(Callfilter,
......
......@@ -226,4 +226,5 @@ class ForwardTypeConverter(object):
Hint = namedtuple('Hint', ['user_id', 'extension', 'argument', 'mediaserver'])
HintWithOptions = namedtuple('Hint', ['user_id', 'extension', 'argument', 'mediaserver', 'options'])
Forward = namedtuple('Forward', ['user_id', 'type', 'number'])
......@@ -23,7 +23,7 @@ from xivo_dao.alchemy.callfiltermember import Callfiltermember
from xivo_dao.resources.func_key.tests.test_helpers import FuncKeyHelper
from xivo_dao.resources.func_key import hint_dao
from xivo_dao.resources.func_key.model import Hint
from xivo_dao.resources.func_key.model import Hint, HintWithOptions
class TestProgfunckeyExtension(DAOTestCase):
......@@ -59,7 +59,8 @@ class TestHints(DAOTestCase, FuncKeyHelper):
self.setup_funckeys()
self.context = 'mycontext'
def add_user_and_func_key(self, protocol='sip', protocol_id=None, exten='1000', commented=0, enablehint=1, configregistrar='default'):
def add_user_and_func_key(self, protocol='sip', protocol_id=None, exten='1000', commented=0, enablehint=1,
configregistrar='default'):
if not protocol_id:
protocol_id = self.add_usersip().id
user_row = self.add_user_line_extension(protocol, protocol_id, exten, commented, enablehint, configregistrar)
......@@ -67,8 +68,8 @@ class TestHints(DAOTestCase, FuncKeyHelper):
return user_row
def add_user_line_extension(self, protocol, protocol_id, exten, commented=0, enablehint=1, configregistrar='default'):
def add_user_line_extension(self, protocol, protocol_id, exten, commented=0, enablehint=1,
configregistrar='default'):
user_row = self.add_user(enablehint=enablehint)
line_row = self.add_line(context=self.context,
protocol=protocol,
......@@ -91,10 +92,11 @@ class TestUserHints(TestHints):
usersip_row = self.add_usersip(name='abcdef')
user_row = self.add_user_and_func_key('sip', usersip_row.id)
expected = Hint(user_id=user_row.id,
extension='1000',
argument='SIP/abcdef',
mediaserver='default')
expected = HintWithOptions(user_id=user_row.id,
extension='1000',
argument='SIP/abcdef',
mediaserver='default',
options=[])
assert_that(hint_dao.user_hints(self.context), contains(expected))
......@@ -103,10 +105,11 @@ class TestUserHints(TestHints):
usersip_row = self.add_usersip(name='abcdef')
user_row = self.add_user_and_func_key('sip', usersip_row.id, 1000, 0, 1, 'mds1')
expected = Hint(user_id=user_row.id,
extension='1000',
argument='SIP/abcdef',
mediaserver='mds1')
expected = HintWithOptions(user_id=user_row.id,
extension='1000',
argument='SIP/abcdef',
mediaserver='mds1',
options=[])
assert_that(hint_dao.user_hints(self.context), contains(expected))
......@@ -114,10 +117,11 @@ class TestUserHints(TestHints):
sccpline_row = self.add_sccpline(name='1001', context=self.context)
user_row = self.add_user_and_func_key('sccp', sccpline_row.id, '1001')
expected = Hint(user_id=user_row.id,
extension='1001',
argument='SCCP/1001',
mediaserver='default')
expected = HintWithOptions(user_id=user_row.id,
extension='1001',
argument='SCCP/1001',
mediaserver='default',
options=None)
assert_that(hint_dao.user_hints(self.context), contains(expected))
......@@ -125,10 +129,11 @@ class TestUserHints(TestHints):
custom_row = self.add_usercustom(interface='ghijkl', context=self.context)
user_row = self.add_user_and_func_key('custom', custom_row.id, '1002')
expected = Hint(user_id=user_row.id,
extension='1002',
argument='ghijkl',
mediaserver='default')
expected = HintWithOptions(user_id=user_row.id,
extension='1002',
argument='ghijkl',
mediaserver='default',
options=None)
assert_that(hint_dao.user_hints(self.context), contains(expected))
......@@ -432,7 +437,7 @@ class TestBSFilterHints(TestHints):
def create_boss_and_secretary(self, commented=0, mediaserver='default'):
if mediaserver != 'default':
self.add_mediaserver(name=mediaserver, display_name='MDS1', voip_ip='10.10.0.1')
boss_row = self.add_user_and_func_key(exten='1000', configregistrar=mediaserver)
secretary_row = self.add_user_and_func_key(exten='1001', configregistrar=mediaserver)
......
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