|
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
|
|
|
#from pyfreebilling.pyfreebill.models import Ratecard, Providertariff |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
class Did(models.Model): |
|
24
|
|
|
""" |
|
25
|
|
|
DID model |
|
26
|
|
|
""" |
|
27
|
|
|
number = models.CharField(_(u'DID number'), |
|
28
|
|
|
max_length=30, |
|
29
|
|
|
db_index=True, |
|
30
|
|
|
unique=True) |
|
31
|
|
|
provider = models.ForeignKey( |
|
32
|
|
|
'pyfreebill.Company', |
|
33
|
|
|
on_delete=models.CASCADE, |
|
34
|
|
|
related_name='didprovider', |
|
35
|
|
|
verbose_name=_(u"Provider"), |
|
36
|
|
|
limit_choices_to={'supplier_enabled': True}) |
|
37
|
|
|
prov_ratecard = models.ForeignKey( |
|
38
|
|
|
'pyfreebill.Providertariff', |
|
39
|
|
|
on_delete=models.CASCADE, |
|
40
|
|
|
verbose_name=_(u"provider rate plan"), |
|
41
|
|
|
null=True, |
|
42
|
|
|
blank=True, |
|
43
|
|
|
limit_choices_to={'enabled': True}) |
|
44
|
|
|
prov_max_channels = models.PositiveIntegerField( |
|
45
|
|
|
_(u'provider channels'), |
|
46
|
|
|
default=0, |
|
47
|
|
|
help_text=_(u"""maximum simultaneous calls allowed |
|
48
|
|
|
for this did. 0 means no limit""")) |
|
49
|
|
|
customer = models.ForeignKey( |
|
50
|
|
|
'pyfreebill.Company', |
|
51
|
|
|
on_delete=models.SET_NULL, |
|
52
|
|
|
related_name='didcustomer', |
|
53
|
|
|
verbose_name=_(u"Customer"), |
|
54
|
|
|
null=True, |
|
55
|
|
|
blank=True, |
|
56
|
|
|
limit_choices_to={'customer_enabled': True}) |
|
57
|
|
|
cust_ratecard = models.ForeignKey( |
|
58
|
|
|
'pyfreebill.ratecard', |
|
59
|
|
|
on_delete=models.SET_NULL, |
|
60
|
|
|
verbose_name=_(u"Customer rate plan"), |
|
61
|
|
|
null=True, |
|
62
|
|
|
blank=True, |
|
63
|
|
|
limit_choices_to={'enabled': True, 'rctype': 'DIDIN'}) |
|
64
|
|
|
cust_max_channels = models.PositiveIntegerField( |
|
65
|
|
|
_(u'customer channels'), |
|
66
|
|
|
default=0, |
|
67
|
|
|
null=True, |
|
68
|
|
|
blank=True, |
|
69
|
|
|
help_text=_(u"""maximum simultaneous calls allowed |
|
70
|
|
|
for this did. 0 means no limit""")) |
|
71
|
|
|
insee_code = models.CharField( |
|
72
|
|
|
_(u'Special code for routing urgency numbers'), |
|
73
|
|
|
null=True, |
|
74
|
|
|
blank=True, |
|
75
|
|
|
max_length=10, |
|
76
|
|
|
help_text=_(u"""Postal code, INSEE code ... for routing |
|
77
|
|
|
urgency number to the right urgency call center.""")) |
|
78
|
|
|
description = models.TextField(_(u'description'), |
|
79
|
|
|
blank=True) |
|
80
|
|
|
date_added = models.DateTimeField(_(u'date added'), |
|
81
|
|
|
auto_now_add=True) |
|
82
|
|
|
date_modified = models.DateTimeField(_(u'date modified'), |
|
83
|
|
|
auto_now=True) |
|
84
|
|
|
|
|
85
|
|
|
class Meta: |
|
86
|
|
|
db_table = 'did' |
|
87
|
|
|
app_label = 'did' |
|
88
|
|
|
ordering = ('number', ) |
|
89
|
|
|
verbose_name = _(u'DID') |
|
90
|
|
|
verbose_name_plural = _(u'DIDs') |
|
91
|
|
|
|
|
92
|
|
|
def __unicode__(self): |
|
93
|
|
|
return u"%s (:%s)" % (self.number, self.provider) |
|
94
|
|
|
|