Commit 7f878d45 authored by Laurent Meiller's avatar Laurent Meiller

3386 WIP add labels and association table userlabels

parent 02ba5e47
xivo-dao (2020.11.00) xivo-freya; urgency=medium
* 3386 - add labels and user labels
-- Laurent Meiller <lmeiller@avencall.com> Tue, 23 Jun 2020 15:04:11 +0000
xivo-dao (2020.10.00) xivo-freya; urgency=medium
* 3366 - update python lib for Debian10
......
db:
image: postgres:9.4
image: postgres:11.2
expose:
- "5432"
environment:
......
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020 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, String
from xivo_dao.helpers.db_manager import Base
class Labels(Base):
__tablename__ = 'labels'
__table_args__ = (
PrimaryKeyConstraint('id')
)
id = Column(Integer, nullable=False, autoincrement=True)
display_name = Column(String(128), nullable=False)
......@@ -32,6 +32,7 @@ from xivo_dao.alchemy import enum
from xivo_dao.alchemy.cti_profile import CtiProfile
from xivo_dao.alchemy.entity import Entity
from xivo_dao.alchemy.func_key_template import FuncKeyTemplate
from xivo_dao.alchemy.userlabels import UserLabels
from xivo_dao.helpers.db_manager import Base
......@@ -143,6 +144,8 @@ class UserFeatures(Base):
UserLine.main_line == True)""")
voicemail = relationship("Voicemail")
cti_profile = relationship("CtiProfile")
labels = relationship("Label", secondary=UserLabels)
def extrapolate_caller_id(self, extension=None):
default_num = extension.exten if extension else None
......
# -*- coding: utf-8 -*-
# Copyright (C) 2020 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, ForeignKeyConstraint, PrimaryKeyConstraint
from sqlalchemy.types import Integer, String
from sqlalchemy.orm import relationship
from xivo_dao.alchemy.userfeatures import UserFeatures
from xivo_dao.alchemy.labels import Labels
from xivo_dao.helpers.db_manager import Base
class UserLabels(Base):
__tablename__ = 'userlabels'
__table_args__ = (
ForeignKeyConstraint(('user_id',),
('userfeatures.id',),
ondelete='RESTRICT'),
ForeignKeyConstraint(('label_id',),
('labels.id',),
ondelete='RESTRICT'),
)
users = relationship(UserFeatures)
labels = relationship(Labels)
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