Commit 36fbd1be authored by Jean Aunis's avatar Jean Aunis

added 'get_user_join_line' in user_dao

parent 9b6ad7dc
......@@ -922,3 +922,13 @@ class TestUserFeaturesDAO(DAOTestCase):
self.assertTrue(user1 in result)
self.assertTrue(user2 in result)
self.assertFalse(user3 in result)
def test_get_user_join_line(self):
user, line = self._add_user_with_line("my_test", "default")
line.number = "1234"
self.add_me(line)
resultuser, resultline = user_dao.get_user_join_line(user.id)
self.assertEqual(user, resultuser)
self.assertEqual(line, resultline)
self.assertEqual(resultline.number, "1234")
......@@ -15,14 +15,15 @@
# 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 and_
from sqlalchemy.sql.expression import func
from xivo_dao.alchemy.agentfeatures import AgentFeatures
from xivo_dao.alchemy.linefeatures import LineFeatures
from xivo_dao.alchemy.contextinclude import ContextInclude
from xivo_dao.alchemy.cti_profile import CtiProfile
from xivo_dao.alchemy.linefeatures import LineFeatures
from xivo_dao.alchemy.userfeatures import UserFeatures
from sqlalchemy import and_
from xivo_dao.helpers.db_manager import daosession
#the following import is necessary to laod CtiProfiles' definition:
from xivo_dao.alchemy.cti_profile import CtiProfile
def enable_dnd(user_id):
......@@ -397,3 +398,14 @@ def _format_user(user):
'voicemailid': user.voicemailid,
'voicemailtype': user.voicemailtype,
}
@daosession
def get_user_join_line(session, userid):
return session.query(UserFeatures, LineFeatures)\
.filter(UserFeatures.id == userid)\
.filter(UserFeatures.id == LineFeatures.iduserfeatures)\
.first()
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