RateCardAdminForm   A
last analyzed

Size/Duplication

Total Lines 3
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
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 import forms
18
from django.utils.translation import ugettext_lazy as _
19
20
from datetimewidget.widgets import DateTimeWidget
21
22
from .models import Company, RateCard, LCRGroup
23
24
25
class CDRSearchForm(forms.Form):
26
    """VoIP call Report Search Parameters"""
27
    dateTimeOptions = {
28
        'format': 'yyyy-dd-mm hh:ii',
29
        'todayBtn': 'true',
30
        'usetz': 'true',
31
        'usel10n': 'true',
32
        'usei18n': 'true'
33
    }
34
    from_date = forms.CharField(label=_(u'From'), required=False, max_length=20,
35
        widget=DateTimeWidget(options=dateTimeOptions))
36
    to_date = forms.CharField(label=_(u'To'), required=False, max_length=20,
37
        widget=DateTimeWidget(options=dateTimeOptions))
38
    customer_id = forms.ChoiceField(label=_(u'Customer'), required=False)
39
    provider_id = forms.ChoiceField(label=_(u'Provider'), required=False)
40
    ratecard_id = forms.ChoiceField(label=_(u'Customer Ratecard'), required=False)
41
    lcr_id = forms.ChoiceField(label=_(u'LCR Group'), required=False)
42
    dest_num = forms.IntegerField(label=_(u'Destination Number'), required=False,
43
        help_text=_(u'Enter the full number or the first part'))
44
45
    def __init__(self, user, *args, **kwargs):
46
        super(CDRSearchForm, self).__init__(*args, **kwargs)
47
        # Customer list
48
        cust_list = []
49
        cust_list.append((0, _(u'all').upper()))
50
        customer_list = Company.objects.values_list('id', 'name')\
51
                    .filter(customer_enabled='True')\
52
                    .order_by('name')
53
54
        for i in customer_list:
55
            cust_list.append((i[0], i[1]))
56
57
        self.fields['customer_id'].choices = cust_list
58
59
        # Provider list
60
        prov_list = []
61
        prov_list.append((0, _(u'all').upper()))
62
        provider_list = Company.objects.values_list('id', 'name')\
63
                    .filter(supplier_enabled='True')\
64
                    .order_by('name')
65
66
        for i in provider_list:
67
            prov_list.append((i[0], i[1]))
68
69
        self.fields['provider_id'].choices = prov_list
70
71
        # Customer Ratecard list
72
        cratec_list = []
73
        cratec_list.append((0, _(u'all').upper()))
74
        cratecard_list = RateCard.objects.values_list('id', 'name')\
75
                    .order_by('name')
76
77
        for i in cratecard_list:
78
            cratec_list.append((i[0], i[1]))
79
80
        self.fields['ratecard_id'].choices = cratec_list
81
82
        # LCR Group list
83
        lcrg_list = []
84
        lcrg_list.append((0, _(u'all').upper()))
85
        lcrgroup_list = LCRGroup.objects.values_list('id', 'name')\
86
                    .order_by('name')
87
88
        for i in lcrgroup_list:
89
            lcrg_list.append((i[0], i[1]))
90
91
        self.fields['lcr_id'].choices = lcrg_list
92
93
94
class CustomerDirectoryAdminForm(forms.ModelForm):
95
    class Meta:
96
        widgets = {
97
            # 'log_auth_failures': SwitchWidget(attrs={'class': 'switch-small',
98
            #                                 'data-on-label': 'YES',
99
            #                                 'data-off-label': 'NO',
100
            #                                 'data-on': 'success',
101
            #                                 'data-off': 'danger'}),
102
            # 'enabled': SwitchWidget(attrs={'class': 'switch-small',
103
            #                                 'data-on-label': 'YES',
104
            #                                 'data-off-label': 'NO',
105
            #                                 'data-on': 'success',
106
            #                                 'data-off': 'danger'}),
107
            # 'fake_ring': SwitchWidget(attrs={'class': 'switch-small',
108
            #                                 'data-on-label': 'ON',
109
            #                                 'data-off-label': 'OFF',
110
            #                                 'data-on': 'success',
111
            #                                 'data-off': 'danger'}),
112
            # 'cli_debug': SwitchWidget(attrs={'class': 'switch-small',
113
            #                                 'data-on-label': 'ON',
114
            #                                 'data-off-label': 'OFF',
115
            #                                 'data-on': 'warning',
116
            #                                 'data-off': 'info'}),
117
            # 'registration': SwitchWidget(attrs={'class': 'switch-medium',
118
            #                                 'data-on-label': 'Registration',
119
            #                                 'data-off-label': 'No: IP/CIDR',
120
            #                                 'data-on': 'warning',
121
            #                                 'data-off': 'info'}),
122
        }
123
124
125
class RateCardAdminForm(forms.ModelForm):
126
    class Meta:
127
        widgets = {
128
            # 'enabled': SwitchWidget(attrs={'class': 'switch-small',
129
            #                                 'data-on-label': 'ON',
130
            #                                 'data-off-label': 'OFF',
131
            #                                 'data-on': 'success',
132
            #                                 'data-off': 'danger'}),
133
        }
134
135
136
class ProviderTariffAdminForm(forms.ModelForm):
137
    class Meta:
138
        widgets = {
139
            # 'enabled': SwitchWidget(attrs={'class': 'switch-small',
140
            #                                 'data-on-label': 'ON',
141
            #                                 'data-off-label': 'OFF',
142
            #                                 'data-on': 'success',
143
            #                                 'data-off': 'danger'}),
144
        }
145
146
147
class CustomerRateCardsAdminForm(forms.ModelForm):
148
    class Meta:
149
        widgets = {
150
            # 'description': forms.TextInput(attrs={"class": "input-medium"}),
151
            # 'allow_negative_margin': SwitchWidget(attrs={'class': 'switch-small',
152
            #                                 'data-on-label': 'YES',
153
            #                                 'data-off-label': 'NO',
154
            #                                 'data-on': 'danger',
155
            #                                 'data-off': 'success'}),
156
        }
157
158
159
class CustomerRatesAdminForm(forms.ModelForm):
160
    class Meta:
161
        widgets = {
162
            # 'enabled': SwitchWidget(attrs={'class': 'switch-small',
163
            #                                 'data-on-label': 'ON',
164
            #                                 'data-off-label': 'OFF',
165
            #                                 'data-on': 'success',
166
            #                                 'data-off': 'danger'}),
167
        }
168
169
170
class ProviderRatesAdminForm(forms.ModelForm):
171
    class Meta:
172
        widgets = {
173
            # 'enabled': SwitchWidget(attrs={'class': 'switch-small',
174
            #                                 'data-on-label': 'ON',
175
            #                                 'data-off-label': 'OFF',
176
            #                                 'data-on': 'success',
177
            #                                 'data-off': 'danger'}),
178
        }
179
180
181
class CompanyAdminForm(forms.ModelForm):
182
    class Meta:
183
        widgets = {
184
            'max_calls': forms.TextInput(attrs={"class": "input-small"}),
185
            'calls_per_second': forms.TextInput(attrs={"class": "input-small"}),
186
            'credit_limit': forms.TextInput(attrs={"class": "input-small"}),
187
            # 'vat': SwitchWidget(attrs={'class': 'switch-small',
188
            #                                 'data-on-label': 'Yes',
189
            #                                 'data-off-label': 'No',
190
            #                                 'data-on': 'info',
191
            #                                 'data-off': 'warning'}),
192
            # 'vat_number_validated': SwitchWidget(attrs={'class': 'switch-small',
193
            #                                 'data-on-label': 'Yes',
194
            #                                 'data-off-label': 'No',
195
            #                                 'data-on': 'info',
196
            #                                 'data-off': 'warning'}),
197
            # 'prepaid': SwitchWidget(attrs={'class': 'switch-small',
198
            #                                 'data-on': 'success',
199
            #                                 'data-off': 'warning'}),
200
            # 'low_credit_alert_sent': SwitchWidget(attrs={'class': 'switch-small',
201
            #                                 'data-on-label': 'ON',
202
            #                                 'data-off-label': 'OFF',
203
            #                                 'data-on': 'danger',
204
            #                                 'data-off': 'success'}),
205
            # 'account_blocked_alert_sent': SwitchWidget(attrs={'class': 'switch-small',
206
            #                                 'data-on-label': 'ON',
207
            #                                 'data-off-label': 'OFF',
208
            #                                 'data-on': 'danger',
209
            #                                 'data-off': 'success'}),
210
            # 'customer_enabled': SwitchWidget(attrs={'class': 'switch-small',
211
            #                                 'data-on-label': 'ON',
212
            #                                 'data-off-label': 'OFF',
213
            #                                 'data-on': 'success',
214
            #                                 'data-off': 'danger'}),
215
            # 'supplier_enabled': SwitchWidget(attrs={'class': 'switch-small',
216
            #                                 'data-on-label': 'ON',
217
            #                                 'data-off-label': 'OFF',
218
            #                                 'data-on': 'success',
219
            #                                 'data-off': 'danger'}),
220
        }
221