Commit be4877d3 authored by Francois Blackburn's avatar Francois Blackburn

dialaction: add propriety to separate action

parent e8ccebab
......@@ -15,8 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <>
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.schema import Column, PrimaryKeyConstraint, Index
from sqlalchemy.types import Integer, String, TypeDecorator
from sqlalchemy.sql import func
from xivo_dao.helpers.db_manager import Base
from xivo_dao.alchemy import enum
......@@ -72,3 +74,41 @@ class Dialaction(Base):
def type(self):
if not self.action:
return self.action.split(':', 1)[0]
def type(cls):
return func.split_part(cls.action, ':', 1)
def type(self, type_):
if not self.action:
self.action = type_
type_subtype = self.action.split(':', 1)
if len(type_subtype) == 2:
self.action = '{}:{}'.format(type_, type_subtype[1])
self.action = type_
def subtype(self):
if not self.action:
type_subtype = self.action.split(':', 1)
if len(type_subtype) == 2:
return type_subtype[1]
return None
def subtype(cls):
return func.split_part(cls.action, ':', 2)
def subtype(self, subtype):
self.action = '{}:{}'.format(self.type, subtype)
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