f2c754bf8625bdf571582a41668bc41099c7cb4c
[ipypbx] / src / ipypbxweb / models.py
1 # Copyright (c) Stas Shtin, 2010
2
3 # This file is part of IPyPBX.
4
5 # IPyPBX 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 # IPyPBX 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 IPyPBX.  If not, see <http://www.gnu.org/licenses/>.
17
18 from django.db import models
19
20
21 class Connection(models.Model):
22     """
23     Connection to a freeswitch server.
24     """
25     name = models.CharField(max_length=100)
26     local_ip_address = models.IPAddressField()
27     local_port = models.PositiveIntegerField()
28     freeswitch_ip_address = models.IPAddressField()
29     freeswitch_port = models.PositiveIntegerField()
30
31
32 class SipProfile(models.Model):
33     connection = models.ForeignKey(Connection)
34     name = models.CharField(max_length=100)
35     external_rtp_ip = models.CharField(max_length=100)
36     external_sip_ip = models.CharField(max_length=100)
37     rtp_ip = models.CharField(max_length=100)
38     sip_ip = models.CharField(max_length=100)
39     sip_port = models.PositiveIntegerField()
40     accept_blind_registration = models.BooleanField()
41     authenticate_calls = models.BooleanField()
42     is_active = models.BooleanField()
43
44
45 class Domain(models.Model):
46     connection = models.ForeignKey(Connection)
47     sip_profile = models.ForeignKey(SipProfile)
48     host_name = models.CharField(max_length=100)
49     is_active = models.BooleanField()
50
51
52 class Gateway(models.Model):
53     connection = models.ForeignKey(Connection)
54     sip_profile = models.ForeignKey(SipProfile)
55     name = models.CharField(max_length=100)
56     username = models.CharField(max_length=100)
57     password = models.CharField(max_length=100)
58     realm = models.CharField(max_length=100)
59     from_domain = models.CharField(max_length=100)
60     extension = models.CharField(max_length=100)
61     expire_in_seconds = models.PositiveIntegerField()
62     retry_in_seconds = models.PositiveIntegerField()
63     caller_id_in_from_field = models.BooleanField()
64     is_active = models.BooleanField()
65
66
67 class Endpoint(models.Model):
68     connection = models.ForeignKey(Connection)
69     user_id = models.CharField(max_length=100)
70     password = models.CharField(max_length=100)
71     domain = models.ForeignKey(Domain)
72     is_active = models.BooleanField()
73
74
75 class Extension(models.Model):
76     connection = models.ForeignKey(Connection)
77     destination_match = models.CharField(max_length=100)
78     xml_dialplan = models.TextField()
79     domain = models.ForeignKey(Domain, null=True, blank=True)
80     endpoint = models.ForeignKey(Endpoint, null=True, blank=True)
81     authenticate_calls = models.BooleanField()
82     is_active = models.BooleanField()