|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
# Copyright 2013 Mathias WOLFF |
|
3
|
|
|
# This file is part of pyfreebilling. |
|
4
|
|
|
# |
|
5
|
|
|
# pyfreebilling is free software: you can redistribute it and/or modify |
|
6
|
|
|
# it under the terms of the GNU General Public License as published by |
|
7
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
|
8
|
|
|
# (at your option) any later version. |
|
9
|
|
|
# |
|
10
|
|
|
# pyfreebilling is distributed in the hope that it will be useful, |
|
11
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
# GNU General Public License for more details. |
|
14
|
|
|
# |
|
15
|
|
|
# You should have received a copy of the GNU General Public License |
|
16
|
|
|
# along with pyfreebilling. If not, see <http://www.gnu.org/licenses/> |
|
17
|
|
|
|
|
18
|
|
|
from django.db import models |
|
19
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
20
|
|
|
|
|
21
|
|
|
# VOIP SWITCH |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
class VoipSwitch(models.Model): |
|
25
|
|
|
""" |
|
26
|
|
|
VoipSwitch Profile |
|
27
|
|
|
|
|
28
|
|
|
Sample config looks like this: |
|
29
|
|
|
|
|
30
|
|
|
<configuration name="event_socket.conf" description="Socket Client"> |
|
31
|
|
|
<settings> |
|
32
|
|
|
<param name="listen-ip" value="127.0.0.1"/> |
|
33
|
|
|
<param name="listen-port" value="8021"/> |
|
34
|
|
|
<param name="password" value="ClueCon"/> |
|
35
|
|
|
</settings> |
|
36
|
|
|
</configuration> |
|
37
|
|
|
""" |
|
38
|
|
|
|
|
39
|
|
|
FS_RTP = 10 |
|
40
|
|
|
KAM = 0 |
|
41
|
|
|
FS_MESS = 1 |
|
42
|
|
|
|
|
43
|
|
|
name = models.CharField( |
|
44
|
|
|
_(u"Switch name"), |
|
45
|
|
|
max_length=50, |
|
46
|
|
|
help_text=_(u"Switch name")) |
|
47
|
|
|
FSTYPE_CHOICES = ( |
|
48
|
|
|
(FS_RTP, (u"FREESWITCH")), |
|
49
|
|
|
(KAM, _(u"KAMAILIO")), |
|
50
|
|
|
(FS_MESS, _(u"FREESWITCH FOR TECHNICAL VOICE MESSAGES")), |
|
51
|
|
|
) |
|
52
|
|
|
setid = models.IntegerField( |
|
53
|
|
|
_(u"Switch type"), |
|
54
|
|
|
default=KAM, |
|
55
|
|
|
choices=FSTYPE_CHOICES, |
|
56
|
|
|
help_text=_(u"""Select the switch type (Kamailio, FreeSwitch)""")) |
|
57
|
|
|
ip = models.CharField( |
|
58
|
|
|
_(u"switch IP"), |
|
59
|
|
|
max_length=100, |
|
60
|
|
|
default="auto", |
|
61
|
|
|
help_text=_(u"Switch IP.")) |
|
62
|
|
|
esl_listen_ip = models.CharField( |
|
63
|
|
|
_(u"event socket switch IP"), |
|
64
|
|
|
max_length=100, |
|
65
|
|
|
default="127.0.0.1", |
|
66
|
|
|
help_text=_(u"Event socket switch IP.")) |
|
67
|
|
|
esl_listen_port = models.PositiveIntegerField( |
|
68
|
|
|
_(u"event socket switch port"), |
|
69
|
|
|
default="8021", |
|
70
|
|
|
help_text=_(u"Event socket switch port.")) |
|
71
|
|
|
esl_password = models.CharField( |
|
72
|
|
|
_(u"event socket switch password"), |
|
73
|
|
|
max_length=30, |
|
74
|
|
|
default="ClueCon", |
|
75
|
|
|
help_text=_(u"Event socket switch password.")) |
|
76
|
|
|
enabled = models.BooleanField( |
|
77
|
|
|
_(u"Enabled"), |
|
78
|
|
|
default=True) |
|
79
|
|
|
flags = models.PositiveIntegerField( |
|
80
|
|
|
_(u"flags"), |
|
81
|
|
|
default="0", |
|
82
|
|
|
help_text=_(u"Flags.")) |
|
83
|
|
|
priority = models.PositiveIntegerField( |
|
84
|
|
|
_(u"priority"), |
|
85
|
|
|
default="0", |
|
86
|
|
|
help_text=_(u"Priority.")) |
|
87
|
|
|
attrs = models.CharField( |
|
88
|
|
|
_(u"attrs"), |
|
89
|
|
|
max_length=128, |
|
90
|
|
|
default=" ", |
|
91
|
|
|
blank=True, |
|
92
|
|
|
help_text=_(u"Attrs.")) |
|
93
|
|
|
description = models.CharField( |
|
94
|
|
|
_(u"Description"), |
|
95
|
|
|
max_length=64, |
|
96
|
|
|
default=" ", |
|
97
|
|
|
blank=True, |
|
98
|
|
|
help_text=_(u"Description.")) |
|
99
|
|
|
date_added = models.DateTimeField( |
|
100
|
|
|
_(u'date added'), |
|
101
|
|
|
auto_now_add=True) |
|
102
|
|
|
date_modified = models.DateTimeField( |
|
103
|
|
|
_(u'date modified'), |
|
104
|
|
|
auto_now=True) |
|
105
|
|
|
|
|
106
|
|
|
class Meta: |
|
107
|
|
|
db_table = 'fs_switch' |
|
108
|
|
|
app_label = 'switch' |
|
109
|
|
|
ordering = ('name', ) |
|
110
|
|
|
verbose_name = _(u'VoIP Switch') |
|
111
|
|
|
verbose_name_plural = _(u'VoIP Switches') |
|
112
|
|
|
|
|
113
|
|
|
def __unicode__(self): |
|
114
|
|
|
return u"%s (:%s) / %s" % (self.name, self.ip, self.setid) |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
class VoipSwitchProfile(models.Model): |
|
118
|
|
|
""" |
|
119
|
|
|
VoipSwitch Profile link |
|
120
|
|
|
""" |
|
121
|
|
|
|
|
122
|
|
|
sipprofile = models.ForeignKey( |
|
123
|
|
|
'pyfreebill.Sipprofile', |
|
124
|
|
|
on_delete=models.CASCADE, |
|
125
|
|
|
verbose_name=_(u"Sip profile")) |
|
126
|
|
|
fsswitch = models.ForeignKey( |
|
127
|
|
|
VoipSwitch, |
|
128
|
|
|
on_delete=models.CASCADE, |
|
129
|
|
|
verbose_name=_(u"FS server"), |
|
130
|
|
|
limit_choices_to={'setid': 10}) |
|
131
|
|
|
|
|
132
|
|
|
CALLIN = 1 |
|
133
|
|
|
CALLOUT = 2 |
|
134
|
|
|
|
|
135
|
|
|
CALLTYPE_CHOICES = ( |
|
136
|
|
|
(CALLIN, (u"IN")), |
|
137
|
|
|
(CALLOUT, _(u"OUT")), |
|
138
|
|
|
) |
|
139
|
|
|
direction = models.IntegerField( |
|
140
|
|
|
_(u"Call direction"), |
|
141
|
|
|
default=CALLIN, |
|
142
|
|
|
choices=CALLTYPE_CHOICES, |
|
143
|
|
|
help_text=_(u"""Select the direction of calls for this profile""")) |
|
144
|
|
|
ip = models.CharField( |
|
145
|
|
|
_(u"context IP"), |
|
146
|
|
|
max_length=100, |
|
147
|
|
|
default="auto", |
|
148
|
|
|
help_text=_(u"Sofia context IP address.")) |
|
149
|
|
|
priority = models.PositiveIntegerField( |
|
150
|
|
|
_(u"priority"), |
|
151
|
|
|
default="0", |
|
152
|
|
|
help_text=_(u"Priority.")) |
|
153
|
|
|
outbound_proxy = models.ForeignKey( |
|
154
|
|
|
VoipSwitch, |
|
155
|
|
|
on_delete=models.CASCADE, |
|
156
|
|
|
related_name='outboundproxy', |
|
157
|
|
|
blank=True, |
|
158
|
|
|
null=True, |
|
159
|
|
|
verbose_name=_(u"Kamailio server"), |
|
160
|
|
|
limit_choices_to={'setid': 0}) |
|
161
|
|
|
description = models.CharField( |
|
162
|
|
|
_(u"Description"), |
|
163
|
|
|
max_length=64, |
|
164
|
|
|
default=" ", |
|
165
|
|
|
blank=True, |
|
166
|
|
|
help_text=_(u"Description.")) |
|
167
|
|
|
date_added = models.DateTimeField( |
|
168
|
|
|
_(u'date added'), |
|
169
|
|
|
auto_now_add=True) |
|
170
|
|
|
date_modified = models.DateTimeField( |
|
171
|
|
|
_(u'date modified'), |
|
172
|
|
|
auto_now=True) |
|
173
|
|
|
|
|
174
|
|
|
class Meta: |
|
175
|
|
|
db_table = 'fs_switch_profile' |
|
176
|
|
|
app_label = 'switch' |
|
177
|
|
|
ordering = ('fsswitch', 'sipprofile', ) |
|
178
|
|
|
verbose_name = _(u'FS profile') |
|
179
|
|
|
verbose_name_plural = _(u'FS profiles') |
|
180
|
|
|
|
|
181
|
|
|
def __unicode__(self): |
|
182
|
|
|
return u"%s -> %s" % (self.fsswitch, self.sipprofile) |
|
183
|
|
|
|