|
1
|
|
|
# Copyright 2013 Mathias WOLFF |
|
2
|
|
|
# This file is part of pyfreebilling. |
|
3
|
|
|
# |
|
4
|
|
|
# pyfreebilling is free software: you can redistribute it and/or modify |
|
5
|
|
|
# it under the terms of the GNU General Public License as published by |
|
6
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
|
7
|
|
|
# (at your option) any later version. |
|
8
|
|
|
# |
|
9
|
|
|
# pyfreebilling is distributed in the hope that it will be useful, |
|
10
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12
|
|
|
# GNU General Public License for more details. |
|
13
|
|
|
# |
|
14
|
|
|
# You should have received a copy of the GNU General Public License |
|
15
|
|
|
# along with pyfreebilling. If not, see <http://www.gnu.org/licenses/> |
|
16
|
|
|
|
|
17
|
|
|
from django.db import models |
|
18
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
class RoutesDid(models.Model): |
|
22
|
|
|
""" |
|
23
|
|
|
routing plan |
|
24
|
|
|
""" |
|
25
|
|
|
contract_did = models.ForeignKey( |
|
26
|
|
|
'did.Did', |
|
27
|
|
|
on_delete=models.CASCADE, |
|
28
|
|
|
) |
|
29
|
|
|
order = models.IntegerField(default=1) |
|
30
|
|
|
ROUTE_TYPE_CHOICES = ( |
|
31
|
|
|
('s', _(u'SIP Trunk')), |
|
32
|
|
|
('e', _(u'External number')), |
|
33
|
|
|
) |
|
34
|
|
|
type = models.CharField(_(u'Route type'), |
|
35
|
|
|
max_length=2, |
|
36
|
|
|
choices=ROUTE_TYPE_CHOICES, |
|
37
|
|
|
default='m', |
|
38
|
|
|
help_text=_(u"""Routing type : sip trunk (s) or |
|
39
|
|
|
external number (e).""")) |
|
40
|
|
|
trunk = models.ForeignKey( |
|
41
|
|
|
'customerdirectory.CustomerDirectory', |
|
42
|
|
|
# limit_choices_to={'company': contract_did__customer__company} |
|
43
|
|
|
null=True, |
|
44
|
|
|
blank=True, |
|
45
|
|
|
on_delete=models.CASCADE, |
|
46
|
|
|
) |
|
47
|
|
|
number = models.CharField(_(u'destination number'), |
|
48
|
|
|
max_length=30, |
|
49
|
|
|
null=True, |
|
50
|
|
|
blank=True, |
|
51
|
|
|
default='') |
|
52
|
|
|
description = models.TextField(_(u'description'), |
|
53
|
|
|
blank=True) |
|
54
|
|
|
date_added = models.DateTimeField(_(u'date added'), |
|
55
|
|
|
auto_now_add=True) |
|
56
|
|
|
date_modified = models.DateTimeField(_(u'date modified'), |
|
57
|
|
|
auto_now=True) |
|
58
|
|
|
|
|
59
|
|
|
class Meta: |
|
60
|
|
|
db_table = 'did_routes' |
|
61
|
|
|
app_label = 'did' |
|
62
|
|
|
ordering = ('contract_did', ) |
|
63
|
|
|
unique_together = ('contract_did', 'order') |
|
64
|
|
|
verbose_name = _(u'DID route') |
|
65
|
|
|
verbose_name_plural = _(u'DID routes') |
|
66
|
|
|
|
|
67
|
|
|
def __unicode__(self): |
|
68
|
|
|
return u"%s pos:%s (type:%s / %s %s)" % (self.contract_did, |
|
69
|
|
|
self.order, |
|
70
|
|
|
self.type, |
|
71
|
|
|
self.number, |
|
72
|
|
|
self.trunk) |
|
73
|
|
|
|