Commit eae9c5e0 authored by Etienne Allovon's avatar Etienne Allovon

Merge branch '2018.05' into 2412-confgend-can-not-generate-conf-due-to-sqlalchemy-security-update

parents 556dab7c 18c1f191
xivo-dao (2017.11.22) xivo-polaris; urgency=medium
xivo-dao (2018.05.12) xivo-aldebaran; urgency=medium
* Fix incompatibility with security patch of SQLAlechemy
-- Jirka HLAVACEK <jhlavacek@avencall.com> Mon, 25 Mar 2019 13:21:17 +0100
xivo-dao (2018.05.05) xivo-aldebaran; urgency=medium
* 1946 Can't update cti profile via csv if cti profile hasn't existed before
-- Tomas Taraba <ttaraba@avencall.com> Wed, 04 Jul 2018 10:50:12 +0200
xivo-dao (2018.05.03) xivo-aldebaran; urgency=medium
[Tomas Taraba]
* 1782 Fix outgoing caller id and call permissions when unc. fwd
[Vojtech Sodoma]
* 1810 Create qualification tables on new xivo
-- Tomas Taraba <ttaraba@avencall.com> Tue, 15 May 2018 10:25:12 +0200
xivo-dao (2018.04.00) xivo-aldebaran; urgency=medium
* 1722 Update Meetmefeatures table schema
* 1722 Remvoe Meetmeguest table
-- Etienne Allovon <eallovon@avencall.com> Fri, 23 Feb 2018 12:18:34 +0100
xivo-dao (2018.02.00) xivo-aldebaran; urgency=medium
* Add get xivo user id from peer
-- Tomas Taraba <ttaraba@avencall.com> Thu, 04 Jan 2018 13:23:07 +0100
xivo-dao (2018.01.00) xivo-aldebaran; urgency=medium
* 1418 Deactivate enablexfer for new users
-- Vojtech Sodoma <vsodoma@avencall.com> Tue, 12 Dec 2017 12:12:50 +0100
xivo-dao (2017.10.00) xivo-dev; urgency=medium
* Set default values for new user:
......
......@@ -71,7 +71,6 @@ from xivo_dao.alchemy.ldapserver import LdapServer
from xivo_dao.alchemy.linefeatures import LineFeatures
from xivo_dao.alchemy.mail import Mail
from xivo_dao.alchemy.meetmefeatures import MeetmeFeatures
from xivo_dao.alchemy.meetmeguest import MeetmeGuest
from xivo_dao.alchemy.monitoring import Monitoring
from xivo_dao.alchemy.musiconhold import MusicOnHold
from xivo_dao.alchemy.netiface import Netiface
......@@ -86,8 +85,11 @@ from xivo_dao.alchemy.phonefunckey import PhoneFunckey
from xivo_dao.alchemy.pickup import Pickup
from xivo_dao.alchemy.pickupmember import PickupMember
from xivo_dao.alchemy.provisioning import Provisioning
from xivo_dao.alchemy.qualification_answers import QualificationAnswers
from xivo_dao.alchemy.qualifications import Qualifications
from xivo_dao.alchemy.queue import Queue
from xivo_dao.alchemy.queue_log import QueueLog
from xivo_dao.alchemy.queue_qualification import QueueQualification
from xivo_dao.alchemy.queuefeatures import QueueFeatures
from xivo_dao.alchemy.queueinfo import QueueInfo
from xivo_dao.alchemy.queuemember import QueueMember
......@@ -123,6 +125,7 @@ from xivo_dao.alchemy.stats_conf import StatsConf
from xivo_dao.alchemy.stats_conf_agent import StatsConfAgent
from xivo_dao.alchemy.stats_conf_queue import StatsConfQueue
from xivo_dao.alchemy.stats_conf_xivouser import StatsConfXivoUser
from xivo_dao.alchemy.subqualifications import Subqualifications
from xivo_dao.alchemy.trunkfeatures import TrunkFeatures
from xivo_dao.alchemy.user import User
from xivo_dao.alchemy.user_contact import UserContact
......
# -*- coding: utf-8 -*-
# Copyright (C) 2007-2015 Avencall
# Copyright (C) 2007-2018 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -27,74 +27,30 @@ class MeetmeFeatures(Base):
__table_args__ = (
PrimaryKeyConstraint('id'),
UniqueConstraint('meetmeid'),
UniqueConstraint('name'),
Index('meetmefeatures__idx__context', 'context'),
Index('meetmefeatures__idx__number', 'confno'),
)
id = Column(Integer, nullable=False)
meetmeid = Column(Integer, nullable=False)
name = Column(String(80), nullable=False)
name = Column(String(128), nullable=False)
confno = Column(String(40), nullable=False)
context = Column(String(39), nullable=False)
admin_typefrom = Column(Enum('none', 'internal', 'external', 'undefined',
name='meetmefeatures_admin_typefrom',
metadata=Base.metadata))
admin_internalid = Column(Integer)
admin_externalid = Column(String(40))
admin_identification = Column(Enum('calleridnum', 'pin', 'all',
name='meetmefeatures_admin_identification',
metadata=Base.metadata),
nullable=False)
admin_mode = Column(Enum('listen', 'talk', 'all',
name='meetmefeatures_mode',
metadata=Base.metadata),
nullable=False)
admin_announceusercount = Column(Integer, nullable=False, server_default='0')
admin_announcejoinleave = Column(Enum('no', 'yes', 'noreview',
name='meetmefeatures_announcejoinleave',
metadata=Base.metadata),
nullable=False)
admin_moderationmode = Column(Integer, nullable=False, server_default='0')
admin_initiallymuted = Column(Integer, nullable=False, server_default='0')
admin_musiconhold = Column(String(128))
admin_poundexit = Column(Integer, nullable=False, server_default='0')
admin_quiet = Column(Integer, nullable=False, server_default='0')
admin_starmenu = Column(Integer, nullable=False, server_default='0')
admin_closeconflastmarkedexit = Column(Integer, nullable=False, server_default='0')
admin_enableexitcontext = Column(Integer, nullable=False, server_default='0')
admin_exitcontext = Column(String(39))
user_mode = Column(Enum('listen', 'talk', 'all',
name='meetmefeatures_mode',
metadata=Base.metadata),
nullable=False)
user_announceusercount = Column(Integer, nullable=False, server_default='0')
user_hiddencalls = Column(Integer, nullable=False, server_default='0')
announceusercount = Column(Integer, nullable=False, server_default='0')
user_announcejoinleave = Column(Enum('no', 'yes', 'noreview',
name='meetmefeatures_announcejoinleave',
metadata=Base.metadata),
nullable=False)
user_initiallymuted = Column(Integer, nullable=False, server_default='0')
user_musiconhold = Column(String(128))
user_poundexit = Column(Integer, nullable=False, server_default='0')
user_quiet = Column(Integer, nullable=False, server_default='0')
user_starmenu = Column(Integer, nullable=False, server_default='0')
user_enableexitcontext = Column(Integer, nullable=False, server_default='0')
user_exitcontext = Column(String(39))
talkeroptimization = Column(Integer, nullable=False, server_default='0')
musiconhold = Column(String(128))
quiet = Column(Integer, nullable=False, server_default='0')
record = Column(Integer, nullable=False, server_default='0')
talkerdetection = Column(Integer, nullable=False, server_default='0')
noplaymsgfirstenter = Column(Integer, nullable=False, server_default='0')
durationm = Column(Integer)
closeconfdurationexceeded = Column(Integer, nullable=False, server_default='0')
nbuserstartdeductduration = Column(Integer)
timeannounceclose = Column(Integer)
maxusers = Column(Integer, nullable=False, server_default='0')
startdate = Column(Integer)
emailfrom = Column(String(255))
emailfromname = Column(String(255))
emailsubject = Column(String(255))
emailbody = Column(Text, nullable=False)
preprocess_subroutine = Column(String(39))
description = Column(Text, nullable=False)
commented = Column(Integer, server_default='0')
user_pin = Column(String(12))
admin_pin = Column(String(12))
user_waitingroom = Column(Integer, nullable=False, server_default='0')
# -*- coding: utf-8 -*-
# Copyright (C) 2007-2018 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
from sqlalchemy import text
from sqlalchemy.schema import Column, PrimaryKeyConstraint
from sqlalchemy.types import Integer, String, Text, DateTime
from xivo_dao.helpers.db_manager import Base
class QualificationAnswers(Base):
__tablename__ = 'qualification_answers'
__table_args__ = (
PrimaryKeyConstraint('id'),
)
id = Column(Integer, nullable=False)
sub_qualification_id = Column(Integer)
time = Column(DateTime, server_default=text("(current_timestamp at time zone 'utc')"))
callid = Column(String(128), nullable=False)
agent = Column(Integer)
queue = Column(Integer)
first_name = Column(String(128), nullable=True)
last_name = Column(String(128), nullable=True)
comment = Column(String(255), nullable=True)
custom_data = Column(Text, nullable=True)
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Avencall
# Copyright (C) 2007-2018 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -21,15 +21,13 @@ from sqlalchemy.types import Integer, String
from xivo_dao.helpers.db_manager import Base
class MeetmeGuest(Base):
class Qualifications(Base):
__tablename__ = 'meetmeguest'
__tablename__ = 'qualifications'
__table_args__ = (
PrimaryKeyConstraint('id'),
)
id = Column(Integer, nullable=False)
meetmefeaturesid = Column(Integer, nullable=False)
fullname = Column(String(255), nullable=False)
telephonenumber = Column(String(40))
email = Column(String(320))
name = Column(String(128), nullable=False)
active = Column(Integer, nullable=False, server_default='1')
# -*- coding: utf-8 -*-
# Copyright (C) 2007-2018 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
from sqlalchemy.schema import Column, PrimaryKeyConstraint
from sqlalchemy.types import Integer
from xivo_dao.helpers.db_manager import Base
class QueueQualification(Base):
__tablename__ = 'queue_qualification'
__table_args__ = (
PrimaryKeyConstraint('id'),
)
id = Column(Integer, nullable=False)
queue_id = Column(Integer, nullable=False)
qualification_id = Column(Integer, nullable=False)
# -*- coding: utf-8 -*-
# Copyright (C) 2007-2018 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
from sqlalchemy.schema import Column, PrimaryKeyConstraint, ForeignKeyConstraint
from sqlalchemy.types import Integer, String
from xivo_dao.helpers.db_manager import Base
class Subqualifications(Base):
__tablename__ = 'subqualifications'
__table_args__ = (
PrimaryKeyConstraint('id'),
ForeignKeyConstraint(['qualification_id'], ['qualifications.id'])
)
id = Column(Integer, nullable=False)
name = Column(String(128), nullable=False)
qualification_id = Column(Integer, nullable=False)
active = Column(Integer, nullable=False, server_default='1')
......@@ -102,7 +102,7 @@ class UserFeatures(Base):
cti_profile_id = Column(Integer)
enablehint = Column(Integer, nullable=False, server_default='1')
enablevoicemail = Column(Integer, nullable=False, server_default='0')
enablexfer = Column(Integer, nullable=False, server_default='1')
enablexfer = Column(Integer, nullable=False, server_default='0')
enableonlinerec = Column(Integer, nullable=False, server_default='0')
callrecord = Column(Integer, nullable=False, server_default='0')
incallfilter = Column(Integer, nullable=False, server_default='0')
......
# -*- coding: utf-8 -*-
# Copyright (C) 2013-2015 Avencall
# Copyright (C) 2013-2018 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -80,4 +80,8 @@ def get_config(session, meetme_id):
def muted_on_join_by_number(number):
return _get_by_number(number).user_initiallymuted == 1
# The initiallymuted parameter was removed
# Function left for legacy compatibilty with xivo-ctid/xivoclient
# we always send False (as it can't be configured anymore)
_get_by_number(number)
return False
......@@ -521,7 +521,7 @@ class TestCreate(TestUser):
preprocess_subroutine=none(),
userfield=none(),
voicemail_id=none(),
call_transfer_enabled=True,
call_transfer_enabled=False,
dnd_enabled=False,
incallfilter_enabled=False,
supervision_enabled=True,
......@@ -549,7 +549,7 @@ class TestCreate(TestUser):
musiconhold='',
voicemailid=none(),
enablehint=1,
enablexfer=1,
enablexfer=0,
incallfilter=0,
enablednd=0,
enableonlinerec=0,
......@@ -581,7 +581,7 @@ class TestCreate(TestUser):
preprocess_subroutine='preprocess_subroutine',
voicemail_id=voicemail.id,
userfield='userfield',
call_transfer_enabled=False,
call_transfer_enabled=True,
dnd_enabled=True,
incallfilter_enabled=True,
supervision_enabled=False,
......@@ -618,7 +618,7 @@ class TestCreate(TestUser):
music_on_hold='music_on_hold',
preprocess_subroutine='preprocess_subroutine',
voicemail_id=voicemail.id,
call_transfer_enabled=False,
call_transfer_enabled=True,
dnd_enabled=True,
incallfilter_enabled=True,
supervision_enabled=False,
......@@ -643,7 +643,7 @@ class TestCreate(TestUser):
passwdclient='password',
voicemailid=voicemail.id,
enablehint=0,
enablexfer=0,
enablexfer=1,
incallfilter=1,
enablednd=1,
enableonlinerec=1,
......
......@@ -36,7 +36,9 @@ class UserCtiProfile(NewModel):
FIELDS = [
'user_id',
'cti_profile_id',
'enabled'
'enabled',
'username',
'password'
]
_RELATION = {}
......
......@@ -436,12 +436,7 @@ class DAOTestCase(unittest.TestCase):
kwargs.setdefault('name', self._random_name())
kwargs.setdefault('confno', ''.join(random.choice('0123456789') for _ in range(6)))
kwargs.setdefault('context', self._random_name())
kwargs.setdefault('admin_identification', 'all')
kwargs.setdefault('admin_mode', 'all')
kwargs.setdefault('admin_announcejoinleave', 'no')
kwargs.setdefault('user_mode', 'all')
kwargs.setdefault('user_announcejoinleave', 'no')
kwargs.setdefault('emailbody', '')
kwargs.setdefault('description', '')
meetmefeatures = MeetmeFeatures(**kwargs)
self.add_me(meetmefeatures)
......
# -*- coding: utf-8 -*-
# Copyright (C) 2007-2015 Avencall
# Copyright (C) 2007-2018 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -39,12 +39,7 @@ class TestMeetmeFeaturesDAO(DAOTestCase):
meetme.confno = confno
meetme.meetmeid = static_meetme.id
meetme.context = context
meetme.admin_identification = 'all'
meetme.admin_mode = 'all'
meetme.admin_announcejoinleave = 'no'
meetme.user_mode = 'all'
meetme.user_announcejoinleave = 'no'
meetme.emailbody = ''
meetme.description = ''
self.add_me(meetme)
......@@ -124,10 +119,6 @@ class TestMeetmeFeaturesDAO(DAOTestCase):
self.assertFalse(meetme_dao.muted_on_join_by_number('9000'))
red.user_initiallymuted = 1
self.assertTrue(meetme_dao.muted_on_join_by_number('9000'))
self.assertRaises(LookupError, meetme_dao.muted_on_join_by_number, '9009')
def test_get_by_number(self):
......
......@@ -217,3 +217,33 @@ class TestUserLineDAO(DAOTestCase):
line = self.add_line()
self.assertRaises(LookupError, user_line_dao.get_with_line_id, line.id)
@patch('xivo_dao.user_line_dao._get_id_for_sip_peer')
def test_get_id_from_peer(self, get_sip_cid):
user_id = (1,)[0]
peer = 'SIP/abcde'
get_sip_cid.return_value = user_id
result = user_line_dao.get_id_from_peer(peer)
self.assertEqual(result, user_id)
def test_get_user_id_from_reassociated_user_line(self):
channel_1 = 'SIP/dddddd-5555'
channel_2 = 'SIP/aabbcc-6789'
user = self.add_user()
self.add_usersip(id=user.id)
line_1 = self.add_line(name='dddddd', protocol='sip')
self.add_user_line(user_id=user.id, line_id=line_1.id)
id_1 = user_line_dao.get_id_from_channel(channel_1)
line_2 = self.add_line(name='aabbcc', protocol='sip')
self.add_user_line(user_id=user.id, line_id=line_2.id)
id_2 = user_line_dao.get_id_from_channel(channel_2)
self.assertEqual(isinstance(id_1, int), True)
self.assertEqual(id_1, id_2)
......@@ -241,10 +241,28 @@ def get_id_from_channel(channel):
return ""
def get_id_from_peer(peer):
protocol = peer.split('/', 1)[0].lower()
if protocol == 'sip':
sip_channel_id = _get_id_for_sip_peer(peer)
return sip_channel_id if isinstance(sip_channel_id, int) else ""
else:
return ""
@daosession
def _get_id_for_sip_channel(session, channel):
proto, name = _get_proto_name(channel, 'sip')
user_id = session.query(UserSIP.id).filter(UserSIP.name == name)[0]
user_sip_line_id = session.query(LineSchema.id).filter(LineSchema.name == name)[0]
user_id = session.query(UserLine.user_id).filter(UserLine.line_id == user_sip_line_id)[0]
return user_id[0]
@daosession
def _get_id_for_sip_peer(session, peer):
proto, name = _get_proto_name_peer(peer, 'sip')
user_sip_line_id = session.query(LineSchema.id).filter(LineSchema.name == name)[0]
user_id = session.query(UserLine.user_id).filter(UserLine.line_id == user_sip_line_id)[0]
return user_id[0]
......@@ -275,3 +293,11 @@ def _get_proto_name(channel, expected_proto):
raise ValueError('Not a %s channel' % expected_proto.upper())
return proto_iface.protocol, proto_iface.interface
def _get_proto_name_peer(channel, expected_proto):
proto_iface = protocol_interface.protocol_interface_from_peer(channel)
if proto_iface.protocol.lower() != expected_proto.lower():
raise ValueError('Not a %s peer' % expected_proto.upper())
return proto_iface.protocol, proto_iface.interface
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